2

I have one little trouble. I created a Localizable.string file for a language which is not in the list of available languages in the General settings of the device.

How to force an app to read from it even if language is set to English? I can set Region Format for this country but not the language.

Thanks

Marko

Breakpoint
  • 1,511
  • 1
  • 18
  • 41

1 Answers1

1

After some time spending on that I found solution. In fact the answer was setting Region Format to other language, and than change main file to look like this:

int main(int argc, char *argv[])
{    
    @autoreleasepool {

        if ([[[NSLocale currentLocale]localeIdentifier]isEqualToString:@"sl_SI"]) {
            [[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"sl", nil] forKey:@"AppleLanguages"];
        } else {
            [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"AppleLanguages"];
        }

        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}

for setting language to Slovenian. For other language to it similar.

tilo
  • 14,009
  • 6
  • 68
  • 85
  • yes, thats correct but maybe I'd COPY the old AppleLanguages key and manipulate the array instead of replacing it altogether ... you know.. that would then still offer correct fallback – Daij-Djan Jan 18 '13 at 09:12
  • I am not quite sure what do you mean. –  Jan 18 '13 at 09:47
  • hehe sorry.. I mean: you have an array from the OS with {DE,EN,FR,CH,...} (n entries). now you replace it with just 1: {SI}. maybe it'd be better to prefix the existing array:{SI,DE,EN,FR,CH,...} (n+1 entries) – Daij-Djan Jan 18 '13 at 10:58
  • Hmmmm,... yes maybe you are right, but if you need just one language,... or it is some downfall for this approach? –  Jan 21 '13 at 07:25
  • 1
    normally, when a 'main language' isnt supported, the os will fallback to the other languages specified.. for xibs or images or strings file.. whatever -- this is mainly a better safe than sorry proposal :) – Daij-Djan Jan 21 '13 at 08:41