locate language app

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
link76
Posts: 99
Joined: Fri Nov 04, 2011 1:52 pm

locate language app

Post by link76 »

what is the easy way to locate language in an app?

thank you
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10501
Joined: Wed May 06, 2009 2:28 pm

Re: locate language app

Post by dunbarx »

In an app?

Do you mean LiveCode?

Does the "alternateLanguage" function help?

Craig Newman
link76
Posts: 99
Joined: Fri Nov 04, 2011 1:52 pm

Re: locate language app

Post by link76 »

sorry, in livecode but in mobile app, for android and ios.

Identify the device language and change the labels

Thank you
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10501
Joined: Wed May 06, 2009 2:28 pm

Re: locate language app

Post by dunbarx »

Ah.

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

Craig
MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: locate language app

Post 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#####
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10103
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: locate language app

Post 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
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
bwmilby
Posts: 463
Joined: Wed Jun 07, 2017 5:37 am
Contact:

Re: locate language app

Post by bwmilby »

I would agree that profiles are probably overkill for localization purposes.
PBH
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 135
Joined: Sun Feb 20, 2011 4:26 pm
Contact:

Re: locate language app

Post 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
paul@researchware.com
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 154
Joined: Wed Aug 26, 2009 7:42 pm
Contact:

Re: locate language app

Post 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)
Paul Dupuis
Researchware, Inc.
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7423
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: locate language app

Post 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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
Post Reply