简体   繁体   中英

How to localize server-side data that i get in my app

I am using Italian language in my app. I have made a Localizable.string file in English and one in Italian.

It's working OK, and everything is working fine with static data, but there are mostly string responses from the server side. How can I convert them in Italian?

If I get data in different-different any string variable then how I will compare it from localizable.string(Italian).

And I also have server side data in English and Italian language. But in app it comes from server.

Thank you..

you can get your application current language like this :

NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSArray *appleLanguagesArray = [userDefaults objectForKey:@"AppleLanguages"];

// Get Current language of an application...
NSString *currentLanguage = [appleLanguagesArray objectAtIndex:0];
if(currentLanguage==@"en") {
    // English language.
}

The other option is if you have two buttons for two languages, then you can check currently which language is selected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM