Localization with .po and gettext in NDK

484 views
Skip to first unread message

GJTorikian

unread,
Apr 7, 2011, 12:36:57 PM4/7/11
to android-ndk
I asked this question previously, but I can't seem to bump my two-
month old thread: http://groups.google.com/group/android-ndk/browse_thread/thread/f123c7fd4f38b965?tvc=2&q=localization

Perhaps this is a feature of the new Google Groups...

Anyway, I'm an a roadblock, and there does not seem to be any
discussion around this on the net at all.

It appears that Android does not support libintl.h and subsequently
gettext. Even though I can get the phone locale and pass it into C
code, I don't seem to be able to take advantage of PO files for
localized UI text.

Is this accurate? Or is there another way? I would hate to not be able
to provide a translated game...that is already translated !

David Turner

unread,
Apr 7, 2011, 5:12:19 PM4/7/11
to andro...@googlegroups.com, GJTorikian
I think you should be able to build libintl and gettext for Android, and link it to your application.


--
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,
Apr 7, 2011, 8:02:11 PM4/7/11
to android-ndk
David, much appreciated for your response. I've done just that, and
the app compiles!

However, setlocale(LC_ALL, "") still returns 0/false. Setting an
explicit language code, i.e. setlocale(LC_ALL, "fr"), does not appear
to fix the problem.

I'm pretty familiar with localization in C, but it's not clear to me
if something else must be considered for the Android environment.
On Apr 7, 2:12 pm, David Turner <di...@android.com> wrote:
> I think you should be able to build libintl and gettext for Android, and
> link it to your application.
>
>
>
>
>
>
>
> On Thu, Apr 7, 2011 at 6:36 PM, GJTorikian <gjtorik...@gmail.com> wrote:
> > I asked this question previously, but I can't seem to bump my two-
> > month old thread:
> >http://groups.google.com/group/android-ndk/browse_thread/thread/f123c...

David Turner

unread,
Apr 8, 2011, 6:10:07 AM4/8/11
to andro...@googlegroups.com, GJTorikian
Android doesn't provide locale support in its C and C++ runtimes.
This is handled at a higher-level in the application stack, using ICU
(which is not exposed by the NDK, since the ABI is very volatile, and the set of built-in tables varies from device to device, based on customization / size reasons).

You might want to use a different locale implementation. The STLport and GNU libstdc++ do provide then if you're using C++.
Reply all
Reply to author
Forward
0 new messages