Is it possible to "redirect" localizations on iOS?

What I want is simple:

My app has only two languages: English and Simplified Chinese. And I hope that if the system language is Simplified or Traditional Chinese, then Simplified Chinese is used; otherwise English is used.

It seems that most user don't know they can set their secondary preferred language. So I cannot rely on them.


You can use this code to retrieve the user language and set the app language:

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
// Reset system defaults to get the complete language list.
[defaults removeObjectForKey:@"AppleLanguages"];
// Default language choosen by user.
NSString *defLanguage = [defaults objectForKey:@"Language"];
NSArray *sysLangugages = [defaults arrayForKey:@"AppleLanguages"];
// System default language: first element of array.
NSString *sysLanguage = [sysLangugages objectAtIndex:0];
NSArray *array = [NSArray arrayWithObjects:defLanguage, sysLanguage, nil];
[defaults setObject:array forKey:@"AppleLanguages"];

 //To set and get the saved language
 // in the .h
#define LocalizationSetLanguage(language) \
[[LocalizationSystem sharedLocalSystem] setLanguage:(language)]

//in the .m
- (void) setLanguage:(NSString*) language

    lang = language;

- (NSString*) getLanguage

    if (!lang) {
        NSArray* languages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"];

        NSString *preferredLang = [languages objectAtIndex:0];
        lang = preferredLang;

    return lang;

Use AMLocalizedString, you can use this to set your local Language.

Need Your Help

Is it possible to access package scoped methods by reflection in Java 9 with Jigsaw?

java java-9 jigsaw

I have the following code to retrieve the default URLStreamHandlers for http and https which works in Java 8 by accessing the static package scoped method URL.getURLStreamHandler():

Error Parsing .dae (Collada) file... cannot find issue

parsing import export collada

For the past couple of weeks I've been working on creating a custom Collada exporter for Revit Architecture, based on the example give here. In order to ensure that my output is correct, I'm compa...