Localized apps, LANG environment variables, and .po files

131 views
Skip to first unread message

GJTorikian

unread,
Jan 31, 2011, 10:11:09 PM1/31/11
to android-ndk
It is not clear to me how to reference/set the LANG environment
variable in a pure C app in order to provide a localized experience.

I have gettext() calls throughout my code, and I have a .po folder
with some definitions. It seems that the only piece I am unable to
figure out is setting LANG. I can make a call in Java to get the
language settings a user has for his or her device. Can I assume a
language is set already and that the proper .po file will be selected
for localization?

David Turner

unread,
Feb 1, 2011, 3:06:37 AM2/1/11
to andro...@googlegroups.com
Locales are not supported on Android, or to be more precise, anything other than the "C" locale is not supported from native code.
You will thus need to call the VM to get the current locale. According to http://developer.android.com/guide/topics/resources/localization.html this looks like doing the equivalent of:

String locale = context.getResources().getConfiguration().locale.getDisplayName();
through JNI.

Hope this helps


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.


GJTorikian

unread,
Feb 1, 2011, 10:14:56 PM2/1/11
to android-ndk
Thanks very much. I'll try to pass in the locale to the JNI. Cheers!
> > android-ndk...@googlegroups.com<android-ndk%2Bunsubscribe@googlegr oups.com>
> > .
Reply all
Reply to author
Forward
0 new messages