iPhone: localization / internationalization default strings file

…衆ロ難τιáo~ 提交于 2019-12-04 13:18:23

问题


I currently have two supported languages: English and Spanish. Thus I have two main.strings files for each language. One in en.lproj and one in es.lproj.

What I want now is that the English main.strings is the default file if a user with a locale other than en or es arrives at the application, e.g. de or fr.

I know I can set it manually for each string in the code with the defaultString parameter:

NSLocalizedStringWithDefaultValue(key, @"main",[NSBundle mainBundle], defaultString, comment);

But I would prefer to not enter it there again (and have to change it at two places), but rather have the en main.strings file as a default for any other "unsupported" locale.


回答1:


What I want now is that the English main.strings is the default file if a user with a locale other than en or es arrives at the application, e.g. de or fr.

Did you try that? I’m almost certain the application will fall back to the English locale without you doing anything at all. Even the system dialogs will come up in English unless your application explicitly supports the current locale.




回答2:


If you want to avoid this long syntax, I have another solution posted here

Localizing strings in iOS: default (fallback) language?



来源:https://stackoverflow.com/questions/3094349/iphone-localization-internationalization-default-strings-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!