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: Klaus, FourthWorld, heatherlaine, kevinmiller

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

locate language app

Post by link76 » Mon Oct 30, 2017 8:23 am

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

thank you

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6258
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: locate language app

Post by dunbarx » Mon Oct 30, 2017 2:09 pm

In an app?

Do you mean LiveCode?

Does the "alternateLanguage" function help?

Craig Newman

link76
Posts: 98
Joined: Fri Nov 04, 2011 1:52 pm

Re: locate language app

Post by link76 » Mon Oct 30, 2017 3:58 pm

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: 6258
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: locate language app

Post by dunbarx » Mon Oct 30, 2017 5:33 pm

Ah.

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

Craig

MaxV
Posts: 1574
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: locate language app

Post by MaxV » Fri Dec 01, 2017 1:38 pm

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: 7017
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: locate language app

Post by FourthWorld » Sat Dec 02, 2017 2:48 am

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
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

bwmilby
Posts: 280
Joined: Wed Jun 07, 2017 5:37 am
Location: Henrico, VA
Contact:

Re: locate language app

Post by bwmilby » Sat Dec 02, 2017 3:22 am

I would agree that profiles are probably overkill for localization purposes.
Brian Milby

Script Tracker https://github.com/bwmilby/scriptTracker

PBH
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 97
Joined: Sun Feb 20, 2011 4:26 pm
Location: Vancouver Island, BC, Canada. ex.UK
Contact:

Re: locate language app

Post by PBH » Sat Dec 02, 2017 5:05 am

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: 74
Joined: Wed Aug 26, 2009 7:42 pm
Location: Randolph, MA USA
Contact:

Re: locate language app

Post by paul@researchware.com » Sat Dec 02, 2017 2:39 pm

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: 5151
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: locate language app

Post by jacque » Sat Dec 02, 2017 6:10 pm

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

Return to “Getting Started with LiveCode - Complete Beginners”