Showing posts with label multiple language support. Show all posts
Showing posts with label multiple language support. Show all posts

Monday, July 4, 2011

How to change language on iPhone simulator?

Go to :
Settings >  General > International > Language >

Following are the screenshots taken on iPhone simulator.









Tutorial : Localization of iPhone App

If you are confused with long posts describing localization you came across so far, you are in right place.
All the tutorials on this blog are straight to the point , No bullshit.
Let's cut to the chase.

In this post we will be dealing with localization of strings displayed in .m files.
How to localize the .nib or .xib file ? , we will deal with it in the next post. LINK


Ok, We are going to have support for 2 languages in our app: English and German.

We will have 2 directories: en.lproj and de.lproj. We will keep localized file in respective directories.
We will have a text file called Localizable.strings file in "each" directory saved as UTF-16 encoding on TextEdit.

(Note if you can't get over the .rtf format in TextEdit, then just take Localizable.strings file from the Sample Code provided at the end of this post and use it with your own strings.)





























See the directory structure
























Whats in the Localizable.strings ?

In de.lproj > Localizable.strings, I will have keys and values of german strings
"German" = "Duetsch";

German is the key and  Duetsch is the value.



In en.lproj > Localizable.strings,I will have keys and values of english strings
"German" = "German";
German on left is the key and  German on  right is the value.


Note: They both share same "key".








How to access these strings in your code ?

Here, NSString *sString= NSLocalizedString(@"German", @"");

German is the key for which you are getting the string value. In here the value for key German is German or Duetsch depending on language in our Setting of our device.







How to change Language in Setting on iPhone/iPad. LINK


In Sample Code, you will see the output localized string printed on console.
Download the code HERE