Multiple Localizable.strings files in one iOS app

前端 未结 4 1492
余生分开走
余生分开走 2020-12-24 05:17

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 w

4条回答
  •  孤城傲影
    2020-12-24 06:00

    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.

提交回复
热议问题