多个Localizable.strings文件在一个iOS应用程序
有可能有多个组件在应用程序中有单独的本地化
Is it possible to have multiple components that have their separate localizations in an app?
例如,我想在我的应用程序中本地化字符串,但也使用ShareKit本地化(所以我的包将包含2个Localizable.strings在不同的位置)。
所以,ShareKit包含文件夹,如en.lproj和de.lproj包含Localizable.strings文件,我想为我的项目的其余部分创建相同,但保持分开。
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?
有一种方法很简单。
有几个宏用于本地化,其中一个是 NSLocalizedStringFromTable()
。这需要三个参数:
There are several macros for localizing, one of which is NSLocalizedStringFromTable()
. This takes three parameters:
- 要本地化的字符串
- 表名称,文件名
- 注释,就像
NSLocalizedString()
- The string to localize
- The table name, which is just a file name
- The comment, just like in
NSLocalizedString()
如果你使用表名,那么你可以有另一个字符串文件,即如果我做 NSLocalizedStringFromTable(@name,@MyStrings,@whatever
然后把我的字符串在 MyStrings.strings
它会使用。
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.
Gallagher的最新讯息。
See Matt Gallagher's recent post about this.