Page 1 of 1

locate language app

Posted: Mon Oct 30, 2017 8:23 am
by link76
what is the easy way to locate language in an app?

thank you

Re: locate language app

Posted: Mon Oct 30, 2017 2:09 pm
by dunbarx
In an app?

Do you mean LiveCode?

Does the "alternateLanguage" function help?

Craig Newman

Re: locate language app

Posted: Mon Oct 30, 2017 3:58 pm
by link76
sorry, in livecode but in mobile app, for android and ios.

Identify the device language and change the labels

Thank you

Re: locate language app

Posted: Mon Oct 30, 2017 5:33 pm
by dunbarx
Ah.

I do not develop for mobile, but does the "mobilePreferredlanguage" help?

Craig

Re: locate language app

Posted: Fri Dec 01, 2017 1:38 pm
by MaxV
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:
  • 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:
########CODE to copy and paste#######
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#####

Re: locate language app

Posted: Sat Dec 02, 2017 2:48 am
by FourthWorld
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:
According 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.
http://lists.runrev.com/pipermail/use-l ... 43352.html

Re: locate language app

Posted: Sat Dec 02, 2017 3:22 am
by bwmilby
I would agree that profiles are probably overkill for localization purposes.

Re: locate language app

Posted: Sat Dec 02, 2017 5:05 am
by PBH
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

Re: locate language app

Posted: Sat Dec 02, 2017 2:39 pm
by paul@researchware.com
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)

Re: locate language app

Posted: Sat Dec 02, 2017 6:10 pm
by jacque
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.