ios 制作多语言ios应用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5748600/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 19:39:46  来源:igfitidea点击:

Making multi-language ios app

iosiphonelocalizationxcode4multilingual

提问by Jos

I need to build an app which will be multilingual. For instance, the app will be released in France and the Netherlands. The user needs to select a language when the app first start for the first time. Is there an easier way to do this? In Xcode I saw something about localizations. Does this have anything to do with it?

我需要构建一个多语言的应用程序。例如,该应用程序将在法国和荷兰发布。用户在第一次启动应用程序时需要选择一种语言。有没有更简单的方法来做到这一点?在 Xcode 中,我看到了一些关于本地化的内容。这与它有什么关系吗?

回答by Todd Hopkinson

These are great resources for your localization efforts:

这些是您本地化工作的重要资源:

回答by Milan Kamilya

Xcode 6.0 : It provides wonderful features for Internationalisation and Localisation.("Localizing with Xcode 6" video). For quick usage I write some useful steps.

Xcode 6.0 :它为国际化和本地化提供了出色的功能(“使用 Xcode 6 本地化”视频)。为了快速使用,我写了一些有用的步骤。

Step 1 :

第1步 :

click on project -> info -> scroll down -> localizations -> click on '+' and add your required language -> check as required -> Finish.

单击项目 -> 信息 -> 向下滚动 -> 本地化 -> 单击“+”并添加所需的语言 -> 根据需要检查 -> 完成。

for xcode 6 : click on project -> change target to -> info > scroll down -> localizations -> click on '+' and add your required language -> check as required -> Finish.

对于 xcode 6:单击项目 -> 将目标更改为 -> 信息 > 向下滚动 -> 本地化 -> 单击“+”并添加所需的语言 -> 根据需要检查 -> 完成。

Step 2 :

第2步 :

click on 'Supporting Files' -> right click -> New File -> select Resource on left-side list -> select 'Strings Files' -> next -> name it 'Localizable' -> create

单击“支持文件”-> 右键单击​​-> 新建文件-> 在左侧列表中选择资源-> 选择“字符串文件”-> 下一步-> 将其命名为“可本地化”-> 创建

Step 3 :

第 3 步:

click on newly created file -> go to Utilities -> file inspector -> click on 'Localize..' -> check all language

单击新创建的文件 -> 转到实用程序 -> 文件检查器 -> 单击“本地化..” -> 检查所有语言

Step 4 :

第四步 :

open Localizable.strings(English) write "help" = "I can't help you";

打开 Localizable.strings(English) write "help" = "I can't help you";

here "help" is a key "I can't help you" is a value. You may change them as your wish.

这里“帮助”是一个关键“我帮不了你”是一个值。您可以根据需要更改它们。

open Localizable.strings(French) or the language you have set. write accordingly and you can translate "I can't help you" to any said language.

打开 Localizable.strings(French) 或您设置的语言。相应地写,你可以将“我不能帮你”翻译成任何所说的语言。

Step 5 :

第 5 步:

// for test
NSString *str = NSLocalizedString(@"help", Nil);
NSLog(@"%@",str);

We have done it. You may check.

我们已经做到了。你可以检查一下。

Now, to test goto settings of device -> general -> International -> language -> select said language or the language you have chosen (There are limited languages). Run your app. Hope this will help you. It help me.

现在,要测试设备的转到设置 -> 通用 -> 国际 -> 语言 -> 选择所述语言或您选择的语言(语言有限)。运行您的应用程序。希望这会帮助你。它帮助我。

回答by coneybeare

I would suggest reading the I18n docs. You will never need to ask the user which language they use as this is obtainable through an API call, so you should do the smart thing and use whichever language they have preferred already on their device.

我建议阅读I18n 文档。您永远不需要询问用户他们使用哪种语言,因为这可以通过 API 调用获得,因此您应该明智地使用他们已经在其设备上首选的语言。