Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
654 views
in Technique[技术] by (71.8m points)

localization - How to localize label strings in iOS for a beginner?

Hi I'm very much stuck on the process of localization on iOS.

Here's what I do understand:

  • How to go to the project explorer and set base localizations for different countries
  • How to make a string file and set it to be localized to one of the particular countries chosen within base localization, such as simplified Chinese
  • key value pairs and how to correspond the word "HELLO WORLD" = " some other language"; with in the localized string file

However the app, which has a simple label, with the writing "hello world" when compiled doesn't change to Chinese in a Chinese simulator.

Here's where I think I'm going wrong:

I think I need to connect the strings on the screen to the strings contained within my localized strings file.

And do I make a separate string file for each language?

I'm looking to make a very very simple stub of an app containing nothing but a few labels which are translated into different languages, so I can learn how to make it connect and work so I can use it else where.

There is a storyboard for Chinese, do I have to do any work to that or is it left blank?

After hours of reading documents I seem to be going around in circles, I'm not impressed with Apples documentation on this issue think its missing something.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

For localization, you need to do:

  1. Add different .strings file for each language
  2. Add the Key value for each language file
  3. Use:

NSLocalizedString(yourKey, nil);

or

[[NSBundle mainBundle] localizedStringForKey:(yourKey) value:@"" table:nil]

For getting the localized string of passed key.

Tutorials:

  1. Localization in iOS apps made simple
  2. iPhone Apps Localization Guide
  3. Preparing your iOS app for localization in Xcode

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...