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
201 views
in Technique[技术] by (71.8m points)

iphone - Multiple Localizable.strings files in one iOS app

Is it possible to have multiple components that have their separate localizations in an app?

For example I want to localize strings in my app but also use ShareKit which is localized itself (so my bundle will contain 2 Localizable.strings in different locations). So, ShareKit contains folders like en.lproj and de.lproj that contain Localizable.strings files and I want to create the same for the rest of my project but keep them separate.

I have tried just keeping them separate and that resulted in the strings of my app not being used. Any ideas?

question from:https://stackoverflow.com/questions/4811745/multiple-localizable-strings-files-in-one-ios-app

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

1 Reply

0 votes
by (71.8m points)

There is a way to do this that is quite simple.

There are several macros for localizing, one of which is NSLocalizedStringFromTable(). This takes three parameters:

  1. The string to localize
  2. The table name, which is just a file name
  3. The comment, just like in NSLocalizedString()

If you use a table name then you can have another strings file, i.e. if I do NSLocalizedStringFromTable(@"name", @"MyStrings", @"whatever"); then put my strings in MyStrings.strings it will use that.

See Matt Gallagher's post about this.


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

...