locate language app
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
locate language app
what is the easy way to locate language in an app?
thank you
thank you
-
- VIP Livecode Opensource Backer
- Posts: 9647
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: locate language app
In an app?
Do you mean LiveCode?
Does the "alternateLanguage" function help?
Craig Newman
Do you mean LiveCode?
Does the "alternateLanguage" function help?
Craig Newman
Re: locate language app
sorry, in livecode but in mobile app, for android and ios.
Identify the device language and change the labels
Thank you
Identify the device language and change the labels
Thank you
-
- VIP Livecode Opensource Backer
- Posts: 9647
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: locate language app
Ah.
I do not develop for mobile, but does the "mobilePreferredlanguage" help?
Craig
I do not develop for mobile, but does the "mobilePreferredlanguage" help?
Craig
Re: locate language app
The new versions of liveocode has the profiles working also on mobile.
However profiles can be not so easy, so a simple text file can be the simplest solution:
on changeLang lang
switch lang
case "english"
put 2 into tLang
break
case "italian"
put 3 into tLang
break
case "German"
put 4 into tLang
break
end switch
put specialFolderPath("Engine") & "/translation.txt" into masterTransl
set itemdel to "§"
repeat for each line tLine in MasterTransl
put "set " & item 1 of tLine & " to " & quote & item tLang of tLine & quote into tComm
do tComm
end repeat
end changeLang
#####END OF CODE generated by http://tinyurl.com/j8xf3xq with livecode 9.0.0-dp-10#####
However profiles can be not so easy, so a simple text file can be the simplest solution:
- Create a text file
- separate the item in a row by a special char, for example §
- create a file like this
Code: Select all
the label button "start" of card 1 § START § INIZIO § AFNAG the label button "stop" of card 1 § HALT $ STOP § AFNAG the text of field "example" § English example § italian example § german example
- Use a message like this:
on changeLang lang
switch lang
case "english"
put 2 into tLang
break
case "italian"
put 3 into tLang
break
case "German"
put 4 into tLang
break
end switch
put specialFolderPath("Engine") & "/translation.txt" into masterTransl
set itemdel to "§"
repeat for each line tLine in MasterTransl
put "set " & item 1 of tLine & " to " & quote & item tLang of tLine & quote into tComm
do tComm
end repeat
end changeLang
#####END OF CODE generated by http://tinyurl.com/j8xf3xq with livecode 9.0.0-dp-10#####
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
-
- VIP Livecode Opensource Backer
- Posts: 9823
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: locate language app
I took your question to the use-livecode list, as it seems a very common need yet I couldn't recall an answer for it. Thankfully Paul Hibbert came through for you with this tip:
http://lists.runrev.com/pipermail/use-l ... 43352.htmlAccording to the dictionary, you should be able to use mobileCurrentLocale(), but I don’t know what the specific results would be, as the dictionary example states “en_US” whereas the equivalent result shown in the settings on iOS is “English (U.S.)”, so some careful investigations may be necessary.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: locate language app
I would agree that profiles are probably overkill for localization purposes.
Brian Milby
Script Tracker https://github.com/bwmilby/scriptTracker
Script Tracker https://github.com/bwmilby/scriptTracker
-
- VIP Livecode Opensource Backer
- Posts: 129
- Joined: Sun Feb 20, 2011 4:26 pm
- Location: Vancouver Island, BC, Canada. ex.UK
- Contact:
Re: locate language app
I had a little time to spare this afternoon, so I ran a couple of simple tests on my iPhone 5s:
mobileCurrentLocale() will return a single line depending on the Settings > General > Language & Region iPhone Language choice, in the format "en_US" for English - USA or "fr_CA" for French - Canada
mobilePreferredLanguages() will return a list of preferred languages in a similar format. e.g.
en-US
de-US
…Where the user has added German as a second language under Settings > General > Languages & Regions > Other Languages.
Note: The mobileCurrentLocale() function result uses an underscore to separate the Language and Region, whereas, the mobilePreferredLanguages() function result uses a dash to separate the Language and Region.
Only tested on iOS as I don't have an Android device, I would expect "similar" results, but definitely needs testing.
Paul
mobileCurrentLocale() will return a single line depending on the Settings > General > Language & Region iPhone Language choice, in the format "en_US" for English - USA or "fr_CA" for French - Canada
mobilePreferredLanguages() will return a list of preferred languages in a similar format. e.g.
en-US
de-US
…Where the user has added German as a second language under Settings > General > Languages & Regions > Other Languages.
Note: The mobileCurrentLocale() function result uses an underscore to separate the Language and Region, whereas, the mobilePreferredLanguages() function result uses a dash to separate the Language and Region.
Only tested on iOS as I don't have an Android device, I would expect "similar" results, but definitely needs testing.
Paul
-
- VIP Livecode Opensource Backer
- Posts: 135
- Joined: Wed Aug 26, 2009 7:42 pm
- Location: Randolph, MA USA
- Contact:
Re: locate language app
It is a shame that mobileCurrentLocale() and/or mobilePreferredLanguages() have not yet been generalized for all platforms (i.e. as currentLocale() and preferredLanguages() ) as these attribute are universal on all LiveCode platforms (except perhaps HTML5 where the question would be locale and language of the server or the client)
Paul Dupuis
Researchware, Inc.
Researchware, Inc.
-
- VIP Livecode Opensource Backer
- Posts: 7228
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: locate language app
A quick test on Android shows only the 2-letter language code. My devices return "en". I think you could use just the first part of the iOS version for cross platform use. The regional variations are largely used only to determine spoken dialects. The printed language will be standard everywhere.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com