问题描述
我有一个JSON文件,其中包含一个iOS应用程序中带有字符串的字典.我们的开发团队通过.xliff文件将我们的应用发送给本地化团队. JSON与iOS中的本地化兼容吗?还是应该将其转换为其他文件类型?
我建议使用Apple提供的.strings文件类型
iOS中的本地化实际上非常棒.对于每种使用的语言,都有一个.lproj文件夹,其前缀为 ISO 639-1 语言代码.
在每个文件夹中,您都可以提供一个.strings文件,其中将包含该语言的所有本地化字符串.
例如,您的en.lproj可能有一个"Localizable.strings"文件,如下所示:
"Hello" = "Hello";
"World = "World";
您的es.lproj(西班牙语)可能有一个"Localizable.strings"文件,如下所示:
"Hello" = "Hola";
"World" = "Mundo";
然后,您将开始对整个应用程序中所有面向用户的字符串使用NSLocalizedString.开始可能会花费一些时间,但是这是一个非常有用的系统,它已经内置.请查看 NSHipster的NSLocalized String 条目,以很好地了解它的工作原理以及它如何使您受益. /p>
链接自2015年7月30日起有效
I have a JSON file containing a dictionary with strings in an iOS app. Our dev team sends off our app to a localization team via an .xliff file. Is JSON compatible with localization in iOS? Or should I convert it to some other file type?
I would suggest using the Apple-provided file type of .strings
Localization in iOS is actually really great. You have a .lproj folder for each language that you are using, prefixed by the ISO 639-1 language codes.
Within each of those folders, you can provide a .strings file that would contain all of the localized strings for that language.
For example, your en.lproj could have a "Localizable.strings" file as follows:
"Hello" = "Hello";
"World = "World";
And your es.lproj (Spanish) could have a "Localizable.strings" file as follows:
"Hello" = "Hola";
"World" = "Mundo";
You would then start using NSLocalizedString for all of your user-facing strings throughout your app. It might take a bit of leg-work to get started, but it is a very helpful system that is already built-in. Take a look at NSHipster's NSLocalized String entry for a good read about how this works and how it might benefit you.
Links valid as of July 30, 2015
这篇关于如何使JSON文件可在iOS中本地化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!