Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2108827
  • 博文数量: 413
  • 博客积分: 10926
  • 博客等级: 上将
  • 技术积分: 3862
  • 用 户 组: 普通用户
  • 注册时间: 2006-01-09 18:14
文章分类

全部博文(413)

文章存档

2015年(5)

2014年(1)

2013年(5)

2012年(6)

2011年(138)

2010年(85)

2009年(42)

2008年(46)

2007年(26)

2006年(59)

分类:

2010-04-19 16:50:27

  1. Summary
    1. XCode will create a sub folder end with extentions .lproj for a supported language.
    2. NSLocale
      Cocoa Touch provides an interface to get current locale.
    3. NSLocalizedStrings
      If you want to support multiple languages, you must use NSLocalizedStrings to load string instead of static string, ie.
      Replace the following statement
          NsString *strName = @"Title";
      with
          NSString *strName = NSLocalizedStrings(@"Title", @"This is window's title");
    4. How to match localizable items
      (Please read reference document in chapter Application Localization section Localization Architecture )
    5. ...
  2. Localization Details
    1. Localizing Nib
      1. Single click .xib file on Groups & Files pane of XCode
      2. Press Command-I to open Info window
      3. On Info window, press General tab
      4. Click button that says Make File Localize in lower-left of the window.
        Then the window switch to the Targets tab, look at the Groups & Files pane, the .xib file now has a discloure triangle next to it, click the disclosure triangle to expand it, you will find the .xib has a sub item named English, this is development base language; Go to Finder, you will find a new folder called English.lproj under the project folder, Rather than Apple's localization convention of using ISO language/region code, XCode still use legacy project name for the development base language, so you need to change English.lproj to en.lproj.
      5. Repeat steps 1 ~ 3 to open Info window again
      6. Click button that says Add Localization, a sheet will drop down and ask you to ener the name of the new localization (Don't select language from drop-down menu, as that will use legacy name, we can input ISO language code instead). ie. enter 'fr' for French. Then XCode will create a new localization project folder end with entensions .lproj in your project folder, such as fr.lproj for French, and copy the .xib file there.
      7. Now .xib file on Groups & Files pane in XCode has 2 sub items, English and fr, double click one of them to open the .xib file in Interface Builder, then double click UI elements to enter translated label.
      8. ...
    2. Localizing Images
      (Similar to Localizing Nib)
      1. Single click image file (such as icon.png) on Groups & Files pane of XCode
      2. Press Command-I to open Info window
      3. On Info window, pre General tab
      4. Click button that says Make File Localize in lower-left of the window.
      5. Repeat steps 1 ~ 3 to open Info window again
      6. Click button that says Add Localization
      7. Use Finder to copy localized image to the proper .lproj folder under your project folder
      8. ...
    3. Localizing Application Icon
      (The same as Localizing Images)
    4. Localizing Strings File
      1. Launch Terminal.app in /Applications/Utilities/
      2. cd to the folder of your project
      3. run 'genstrings ./Classes/*.m' to generate strings file in development base language called Localizable.strings in current directory
      4. Import strings file by draggin the it from Finder to Resources folder of your proejct in XCode
      5. On prompt dialog,
        - Uncheck Copy items into destination groups folder (if needed)
        - Change text encoding to Unicode (UTF-16), otherwise, the file will look like gibberish when you open it in XCode
      6. Click button Add
      7. Then the window switch to the Targets tab, single click strings file Localizable.strings on Groups & Files pane of XCode
      8. Press Command-I to open Info window
      9. On Info window, pre General tab
      10. Click button that says Make File Localize in lower-left of the window.
      11. Repeat steps 7 ~ 9 to open Info window again
      12. Click button that says Add Localization
      13. Back to Groups & Files pane of XCode, double click sub items (such as fr) of Localizable.strings to translate string items.
      14. ...
  3. ...

Reference:
  1. Beginning iPhone Development: Exploring the iPhone SDK
    Chapter: Application Localization
    Page: P473~490
阅读(1330) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~