1

I'm pretty stuck with localization inside the app. What is idea: You choose language inside the app, and depends on which language you choose it save value in NSUserDefaults. Because I didn't find material for this kind of localization, my idea is to make class that will have class method that return string depending on which language is saved 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;
}

Is this legit way, is there any better solution?

Stefan
  • 1,283
  • 15
  • 33
  • There was a topic a while ago concerning how to set a localized language regardless of OS's language setting. – El Tomato Oct 21 '15 at 07:27
  • If you can give me link, cause I didn't find that... – Stefan Oct 21 '15 at 07:28
  • stop stop stop... don't do that... ***I will leave programming if you do that...*** – Fahim Parkar Oct 21 '15 at 07:30
  • [this will help you](https://www.google.com.kw/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=localization%20example%20in%20ios%20using%20.strings%20files) – Fahim Parkar Oct 21 '15 at 07:35
  • @FahimParkar I know that this is not way, but time is running out, and I don't have idea how to do on other way. – Stefan Oct 21 '15 at 07:35
  • @FahimParkar, I need solutions that is regardless of iOS language settings. – Stefan Oct 21 '15 at 07:36
  • What you mean by `I need solutions that is regardless of iOS language settings` more details on exactly what you want... – Fahim Parkar Oct 21 '15 at 07:39
  • I want to change app language from the app, I don't want to app be dependent on language from system settings. I have choice of three languages in app, and depending which language is chosen that translate will be shown in app. – Stefan Oct 21 '15 at 07:44

1 Answers1

0

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

Stefan
  • 1,283
  • 15
  • 33