Localization of iOS applications depends on the user's choice in the application

I am pretty stuck in localization inside the application. What is the idea: you choose a language inside the application and depends on which language you choose, save the value in NSUserDefaults . Since I did not find material for this kind of localization, my idea is to create a class that will have a class method that returns a string, depending on which language is stored in NSUserDefaults. Example:

 +(NSString *) helloString { NSString *hello = [NSString new]; if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"language"] isEqualToString:@"en"]) { hello = @"Hello"; } else if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"language"] isEqualToString:@"es"]) { hello = @"Holla!"; } return hello; } 

This is a legal way, is there a better solution?

+1
ios objective-c localization
source share
1 answer

I found a solution for my problem. I used the LocalizationSystem class, which mimicked the changed language from the system settings.

0
source share

All Articles