Localization

691 views
Skip to first unread message

André Fiedler

unread,
Feb 1, 2011, 4:55:21 PM2/1/11
to phon...@googlegroups.com
Is there any way to retrieve the Language of the users device?

Michael

unread,
Feb 2, 2011, 12:24:57 AM2/2/11
to phonegap
> Is there any way to retrieve the Language of the users device?

Lack of reply to this question I've come up with the following code:

var lang;

// PhoneGap on Android would always return EN in navigator.*language.
// Parse userAgent instead...
// Mozilla/5.0 (Linux; U; Android 2.2; de-ch; HTC Desire Build/FRF91)
AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
if ( navigator && navigator.userAgent
&& (lang = navigator.userAgent.match(/android.*\W(\w\w)-(\w\w)\W/i))
) {
lang = lang[1];
}

if (!lang && navigator) {
if (navigator.language) {
lang = navigator.language;
} else if (navigator.browserLanguage) {
lang = navigator.browserLanguage;
} else if (navigator.systemLanguage) {
lang = navigator.systemLanguage;
} else if (navigator.userLanguage) {
lang = navigator.userLanguage;
}

lang = lang.substr(0, 2);
}

André Fiedler

unread,
Feb 2, 2011, 3:14:45 AM2/2/11
to phon...@googlegroups.com
great, thx will try that! :o)

2011/2/2 Michael <michael...@gmail.com>
--
You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en

For more info on PhoneGap or to download the code go to www.phonegap.com

Tue Topholm

unread,
Feb 13, 2011, 3:46:44 PM2/13/11
to phon...@googlegroups.com
I have made a plugin to read from the apps Localizations files:




--

Med venlig hilsen / Kind regards

Tue Topholm
Sugee
Tlf: +45 32 13 32 32
W: http://www.sugee.dk


2011/2/2 André Fiedler <fiedle...@googlemail.com>

Gmail - IJoeR316

unread,
Feb 13, 2011, 4:09:09 PM2/13/11
to phon...@googlegroups.com
is it for Android, iPhone?
 
You should update your README file. its blank.
 
Can u also offer some code examples in your plugin?
 
Thanks!
2011/2/2 André Fiedler <fiedle...@googlemail.com>
2011/2/2 Michael <michael...@gmail.com>


For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en

For more info on PhoneGap or to download the code go to www.phonegap.com

--
You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to

For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
 
For more info on PhoneGap or to download the code go to www.phonegap.com

Vaughn Simon

unread,
Feb 13, 2011, 4:13:18 PM2/13/11
to phon...@googlegroups.com
This is for iOS since *.lproj is mentioned and this dev has previously made an iOS plugin to allow Phonegap to make a native settings/preferences.

Tue Topholm

unread,
Feb 13, 2011, 4:48:06 PM2/13/11
to phon...@googlegroups.com
Hi Joe?

Everything I make at the moment is for the iphone, and under each plugin there is a readme, with examples.

--

Med venlig hilsen / Kind regards

Tue Topholm
Sugee
Tlf: +45 32 13 32 32
W: http://www.sugee.dk


2011/2/13 Vaughn Simon <vaugh...@gmail.com>

Gmail - IJoeR316

unread,
Feb 13, 2011, 4:49:37 PM2/13/11
to phon...@googlegroups.com
hmm, I just looked on github and the readme file at the root of the page is empty. I’m just working on android right now. I’ll be moving to the iPhone soon too so maybe something you got will help me aklong the way. thanks.

André Fiedler

unread,
Feb 14, 2011, 3:31:19 AM2/14/11
to phon...@googlegroups.com
great, i definitely wi take a look at it! :o) 

2011/2/13 Gmail - IJoeR316 <ijoe...@gmail.com>

André Fiedler

unread,
Feb 14, 2011, 3:37:51 AM2/14/11
to phon...@googlegroups.com
Hm, woudn´t it be more flexible, if you write the localized strings in JavaScript (like Mootools Locale: http://goo.gl/kUajv). So it would be easier to port the application to Android, BB, WP7. ;o) Now i have to rewrite the en.lproj files for every platform. :/

Your Localizable plugin should only return the current locale identifier (en-EN or so).

greetings André

2011/2/14 André Fiedler <fiedle...@googlemail.com>

Giacomo Balli

unread,
Feb 14, 2011, 4:08:45 AM2/14/11
to phonegap
why go through all of this when you have info in the useragent?

On Feb 14, 9:37 am, André Fiedler <fiedler.an...@googlemail.com>
wrote:
> Hm, woudn´t it be more flexible, if you write the localized strings in
> JavaScript (like Mootools Locale:http://goo.gl/kUajv). So it would be
> easier to port the application to Android, BB, WP7. ;o) Now i have to
> rewrite the en.lproj files for every platform. :/
>
> Your Localizable plugin should only return the current locale identifier
> (en-EN or so).
>
> greetings André
>
> 2011/2/14 André Fiedler <fiedler.an...@googlemail.com>
>
>
>
> > great, i definitely wi take a look at it! :o)
>
> > 2011/2/13 Gmail - IJoeR316 <ijoer...@gmail.com>
>
> >   hmm, I just looked on github and the readme file at the root of the page
> >> is empty. I’m just working on android right now. I’ll be moving to the
> >> iPhone soon too so maybe something you got will help me aklong the way.
> >> thanks.
>
> >> Thanks!
>
> >>  *From:* Tue Topholm <t...@sugee.dk>
> >> *Sent:* Sunday, February 13, 2011 4:48 PM
> >> *To:* phon...@googlegroups.com
> >> *Subject:* Re: [PhoneGap] Re: Localization
>
> >> Hi Joe?
>
> >> Everything I make at the moment is for the iphone, and under each plugin
> >> there is a readme, with examples.
>
> >> --
>
> >> Med venlig hilsen / Kind regards
>
> >> Tue Topholm
> >> Sugee
> >> Tlf: +45 32 13 32 32
> >> W:http://www.sugee.dk
>
> >> 2011/2/13 Vaughn Simon <vaughnap...@gmail.com>
>
> >>> This is for iOS since *.lproj is mentioned and this dev has previously
> >>> made an iOS plugin to allow Phonegap to make a native settings/preferences.
>
> >>>  On Feb 13, 2011, at 2:09 PM, Gmail - IJoeR316 wrote:
>
> >>>   is it for Android, iPhone?
>
> >>> You should update your README file. its blank.
>
> >>> Can u also offer some code examples in your plugin?
>
> >>> Thanks!
>
> >>>  *From:* Tue Topholm <t...@sugee.dk>
> >>> *Sent:* Sunday, February 13, 2011 3:46 PM
> >>> *To:* phon...@googlegroups.com
> >>> *Subject:* Re: [PhoneGap] Re: Localization
>
> >>> I have made a plugin to read from the apps Localizations files:
>
> >>>https://github.com/ttopholm/phonegap-plugins
>
> >>> --
>
> >>> Med venlig hilsen / Kind regards
>
> >>> Tue Topholm
> >>> Sugee
> >>> Tlf: +45 32 13 32 32
> >>> W:http://www.sugee.dk
>
> >>> 2011/2/2 André Fiedler <fiedler.an...@googlemail.com>
>
> >>>> great, thx will try that! :o)
>
> >>>> 2011/2/2 Michael <michael.her...@gmail.com>
> >>>>> mailto:phonegap%2Bunsu...@googlegroups.com<phonegap%2Bunsubscribe@googl egroups.com>
> >>>>> For more options, visit this group at
> >>>>>http://groups.google.com/group/phonegap?hl=en?hl=en
>
> >>>>> For more info on PhoneGap or to download the code go to
> >>>>>www.phonegap.com
>
> >>>> --
> >>>> You received this message because you are subscribed to the Google
> >>>> Groups "phonegap" group.
> >>>> To post to this group, send email to phon...@googlegroups.com
> >>>> To unsubscribe from this group, send email to
> >>>> mailto:phonegap%2Bunsu...@googlegroups.com<phonegap%2Bunsubscribe@googl egroups.com>
> >>>> For more options, visit this group at
> >>>>http://groups.google.com/group/phonegap?hl=en?hl=en
>
> >>>> For more info on PhoneGap or to download the code go to
> >>>>www.phonegap.com
>
> >>> --
> >>> You received this message because you are subscribed to the Google
> >>> Groups "phonegap" group.
> >>> To post to this group, send email to phon...@googlegroups.com
> >>> To unsubscribe from this group, send email to
> >>> phonegap+u...@googlegroups.com
> >>> For more options, visit this group at
> >>>http://groups.google.com/group/phonegap?hl=en?hl=en
>
> >>> For more info on PhoneGap or to download the code go towww.phonegap.com
>
> >>> --
> >>> You received this message because you are subscribed to the Google
> >>> Groups "phonegap" group.
> >>> To post to this group, send email to phon...@googlegroups.com
> >>> To unsubscribe from this group, send email to
> >>> phonegap+u...@googlegroups.com
> >>> For more options, visit this group at
> >>>http://groups.google.com/group/phonegap?hl=en?hl=en
>
> >>> For more info on PhoneGap or to download the code go towww.phonegap.com
>
> >>>  --
> >>> You received this message because you are subscribed to the Google
> >>> Groups "phonegap" group.
> >>> To post to this group, send email to phon...@googlegroups.com
> >>> To unsubscribe from this group, send email to
> >>> mailto:phonegap%2Bunsu...@googlegroups.com<phonegap%2Bunsubscribe@googl egroups.com>
> >>> For more options, visit this group at
> >>>http://groups.google.com/group/phonegap?hl=en?hl=en
>
> >>> For more info on PhoneGap or to download the code go towww.phonegap.com
>

André Fiedler

unread,
Feb 14, 2011, 4:11:17 AM2/14/11
to phon...@googlegroups.com
Do we have it on all platforms? iOS, Android, BB, WP7? I don´t know it. If so, it´s unnecessary. :o)


2011/2/14 Giacomo Balli <giacom...@gmail.com>

Giacomo Balli

unread,
Feb 14, 2011, 5:32:43 AM2/14/11
to phonegap
any browser has useragent ASAIK

On Feb 14, 10:11 am, André Fiedler <fiedler.an...@googlemail.com>
wrote:
> Do we have it on all platforms? iOS, Android, BB, WP7? I don´t know it. If
> so, it´s unnecessary. :o)
>
> 2011/2/14 Giacomo Balli <giacomoba...@gmail.com>

Tue Topholm

unread,
Feb 14, 2011, 5:58:06 AM2/14/11
to phon...@googlegroups.com
It is IOS only. And yes it could be easier to use js instead.

It returns the language the iphone/ipad is set to, and if you don't have the localizable string en the current locale, it will return in English.


--

Med venlig hilsen / Kind regards

Tue Topholm
Sugee
Tlf: +45 32 13 32 32
W: http://www.sugee.dk


2011/2/14 André Fiedler <fiedle...@googlemail.com>
Reply all
Reply to author
Forward
0 new messages