有没有办法在iOS从Localizable.strings中读取后更改本地化字符串,并仍然保持使用NSLocalizedStringWithDefaultValue(key, table, bundle, value, comment)
的能力?换句话说,是否可以以编程方式更改本地化字符串,例如,在从服务器接收更新的字符串集后?
此问题假定无法修改Localizable.strings,因为这需要修改主NSBundle,安装应用程序后不允许这样做。
答案 0 :(得分:1)
一种方法是创建一个包含所需字符串文件的新捆绑包,并在[NSBundle mainBundle]
中使用该捆绑包而不是NSLocalizedStringWithDefaultValue(...)
。
答案 1 :(得分:0)
将NSLocalizedString
宏重新定义为您想要的任何内容:
#undef NSLocalizedString
#define NSLocalizedString(key, comment) \
[MyLocalizationManager localizedStringForKey:key]