2

I'm currently localizing my iOS-Application. This works pretty decent so far.

I've already created localizable.strings and several xib-files and so about 80% of the app is already translated.

But the App also loads data from a WebService which passes me a key, e.g.: "TITEL 1" as well as all supported languages (values) attached to it e.g: "Titel One" "Titel Eins" "Titolo Uno".

And now i would like to store those values in the according localizable.strings files.

For example:

Localizable.strings (English) should then contain:

"TITLE 1" = "Title One";

Localizable.strings (German) should then contain:

"TITLE 1" = "Titel Eins";

Localizable.strings (Italian) should then contain:

"TITLE 1" = "Titolo Uno";

How can I do this?

2 Answers 2

2

You will not be able to insert them in the localization strings at run time, if the webserver is managed by you, i suggest that you send wich language is the user using, Please consider this example

//Get the language code
NSString* languageCode = [[NSLocale preferredLanguages] objectAtIndex:0];
//Now send the request to the server with the language you want
NSString *str = [NSString stringWithFormat:@"www.yourserve.com/yourfunctiom?lang=%@", languageCode];
//Request it

Now basing on the language that you receive in your server you will return the appropriate string

Sign up to request clarification or add additional context in comments.

1 Comment

You could also get the appropriate string from the hash using that language code, if you are not in control of the server.
0

This may be stretching the frameworks a bit, but if you want to use Apple's string loading functions you could try to build an NSBundle in your document directory (a bundle is just a directory, after all), fill it with files from the server and then use NSLocalizedStringFromTableInBundle to get to your strings.

Not sure it is worth it compared to the approach in Omar Abdelhafith's answer, though.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.