多个Localizable.strings文件在一个iOS应用程序 [英] Multiple Localizable.strings files in one iOS app

查看:697
本文介绍了多个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:


  1. 要本地化的字符串

  2. 表名称,文件名

  3. 注释,就像 NSLocalizedString()

  1. The string to localize
  2. The table name, which is just a file name
  3. 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.

这篇关于多个Localizable.strings文件在一个iOS应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆