0

When you specify a Locale in Android, it will change the strings offered for Date, etc. So if I change my locale to French, France, my Android datepicker will show "Mardi" instead of "Monday".

Where are these translations stored? I've traced the code all the way to libcore.icu.LocaleData, but I can't figure out where it is getting the translations. For instance, in the below code, (link) where are they finding they populating public String[] longMonthNames; ? I've grepped the repo and can't find the resources.

package libcore.icu;
public final class LocaleData {
    // A cache for the locale-specific data.
    private static final HashMap<String, LocaleData> localeDataCache = new HashMap<String, LocaleData>();
    static {
        // Ensure that we pull in the locale data for the root locale, en_US, and the
        // user's default locale. (All devices must support the root locale and en_US,
        // and they're used for various system things like HTTP headers.) Pre-populating
        // the cache is especially useful on Android because we'll share this via the Zygote.
        get(Locale.ROOT);
        get(Locale.US);
        get(Locale.getDefault());
    }
    // Used by Calendar.
    public Integer firstDayOfWeek;
    public Integer minimalDaysInFirstWeek;
    // Used by DateFormatSymbols.
    public String[] amPm; // "AM", "PM".
    public String[] eras; // "BC", "AD".
    public String[] longMonthNames; // "January", ...
    public String[] shortMonthNames; // "Jan", ...
    public String[] tinyMonthNames; // "J", ...
    public String[] longStandAloneMonthNames; // "January", ...
    public String[] shortStandAloneMonthNames; // "Jan", ...
    public String[] tinyStandAloneMonthNames; // "J", ...

The reason I need to do this is because I need to overwrite some of the

Eric S.
  • 1,502
  • 13
  • 31
  • force the locale to US http://stackoverflow.com/questions/2900023/change-language-programatically-in-android – Kirill Kulakov Mar 23 '16 at 17:53
  • Thanks, but that's the easy stuff. I'm trying to make a new locale. – Eric S. Mar 23 '16 at 17:56
  • What are you trying to achieve? sounds like a hack – Kirill Kulakov Mar 23 '16 at 18:00
  • This is not what you should do, but if you really need to, you can make use of locales in which you don't have any translations and switch to them when initializing an activity (and make sure you set locale back to English if one of these is default). But again, it is an ugly hack and you should not do it – Markaos Mar 23 '16 at 18:09
  • What I need to do is make my Android widget DatePicker show Latin Serbian instead of Cyrillic Serbian. Android doesn't have a locale for Serbian Latin, so I wanted to make one or overwrite the month values of the Serbian Cyrllic locale. I traced it to LocaleData but didn't get further. How do you recommend I approach this? – Eric S. Mar 23 '16 at 18:13
  • I suspect the correct solution is to make my own datepicker, but I'd rather not. – Eric S. Mar 23 '16 at 18:15

1 Answers1

0

The translations for Android are stored in

/Sdk/platforms/android-21/data/res/

Eric S.
  • 1,502
  • 13
  • 31