discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Correct Current NSLocale on Android


From: Stefan Bidigaray
Subject: Re: Correct Current NSLocale on Android
Date: Wed, 16 Sep 2020 09:20:53 -0500

On Wed, Sep 16, 2020, 05:23 Stefan Pauwels <stefan@pauwels.ch> wrote:
Hi

I am initializing GNUstep on Android as advised in the tools-android README, i.e. I am calling
[NSUserDefaults setUserLanguages:]
which seems to work for just setting the language, but when I try to rely on the currentLocale (for other information like region, metric system usage, etc.) I always get „en_US_POSIX“ as the locale.

Is there a way to manually init the locale correctly?

Best Regards
Stefan

Hi Stefan,
The locale is set at the operating system or user level, either by using the $LANG shell variable (returned by +systemLocale) or Locale default (returned by +currentLocale).

It's been a long time since I wrote this code, but if I still remember correctly NSLocale falls back to whatever is specified in $LANG if the Locale default is unset. If $LANG is also unset, then it falls back to en_US_POSIX.

You could also also create your own NSLocale using +localeWithLocaleIdentifier:. This will not interfere with the system or current locales.

Stefan

reply via email to

[Prev in Thread] Current Thread [Next in Thread]