简体   繁体   English

如何在模拟器上测试本地化字符串?

[英]How to test localized string on simulator?

I am using NSLocalizedString(); 我正在使用NSLocalizedString(); function for my localized strings. 我的本地化字符串的函数。 Even though i change my preferred language in simulator settings my string still get shown up in English. 即使我在模拟器设置中更改了我的首选语言,我的字符串仍会以英语显示。

Can we test the NSLocalizedString(); 我们可以测试NSLocalizedString(); from simulator? 来自模拟器? if so how? 如果是这样的话?

Can any one guide me through this please? 请问任何人可以指导我吗?

-- Regards, - 问候,

U'suf U'suf

To answer how to test localized string on simulator? 要回答如何在模拟器上测试本地化字符串?

I will assume that you have successfully added the Localizable.strings files for various languages you and you app want to target. 我将假设您已成功为您和应用程序想要定位的各种语言添加了Localizable.strings文件。

Step 1 - Goto target in the run destination. 第1步 - 转到目标中的目标。

在此输入图像描述

Step 2 - Expand the menu to show options and then click on "Edit Scheme" 第2步 - 展开菜单以显示选项,然后单击“编辑方案”

在此输入图像描述

Step 3 - Click on "Run" and then select "Options" . 第3步 - 单击“运行” ,然后选择“选项” Choose the language you want to test for in the drop down available in the "Application Language" “应用程序语言”的下拉列表中选择要测试的语言

在此输入图像描述

Step 4 - CMD + R 第4步 - CMD + R.

That should be it!! 那应该是!!

Please note that if you choose a language for which no Localization.string file was provided then it will show development language, which is more or less English. 请注意,如果您选择的语言没有提供Localization.string文件,那么它将显示开发语言,该语言或多或少是英语。

Another but tedious way is to go to Simulator Settings > General > Language & Region > iPhone Language and choose the language. 另一种繁琐的方法是转到模拟器设置>常规>语言和区域> iPhone语言并选择语言。 Since simulators can be buggy (like mine is) this process can be time consuming. 由于模拟器可能是错误的(就像我的一样),这个过程可能很耗时。 Most of the time requiring rebooting of simulator (yet another time consuming task) for the changes to reflect. 大多数时候需要重新启动模拟器(又一个耗时的任务)才能反映出变化。

Hope it helps! 希望能帮助到你!

Code and Prosper 代码和繁荣

Edit : Official Apple Link . 编辑: 官方Apple Link If anyone is looking. 如果有人在看。 Pointer -> "Testing Specific Languages and Regions" 指针 - > “测试特定语言和区域”

The simulator can get stuck displaying the 'first' language if you have tested the app before it had a second localization. 如果您在第二次本地化之前测试了应用程序,模拟器可能会卡住显示“第一”语言。

The solution (XCode 4.5.2, iOS6) appears to be to delete the app from the simular then reinstall. 解决方案(XCode 4.5.2,iOS6)似乎是从simular中删除应用程序然后重新安装。 After that you can change the language repeatedly and the localizations will appear in the simulator correctly. 之后,您可以重复更改语言,并且本地化将正确显示在模拟器中。

您应该为其他语言准备本地化字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM