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?
ios objective-c localization
Stefan
source share