iPhone应用程序的国际化 [英] internationalization of an iPhone Application

查看:151
本文介绍了iPhone应用程序的国际化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iPhone App开发的新手(我正在使用XCode 4.2),我想知道是否有办法在内部翻译所有字符串,标题等...而无需逐个翻译它们。

I am new to iPhone App development (I am using XCode 4.2) and I was wondering if there is a way to translate all the strings , caption etc ... internally without having to translate them one by one .

我想到的一个想法是使用NSUserDefaults将语言保存为全局变量并相应地翻译所有内容

an idea I have in mind is to use NSUserDefaults to save the language as a global variable and translate everything accordingly

另一个选项是查找表(甚至可以在Objective-C中?)

another option is to make a look up table (is it even possible in Objective-C ?)

谢谢

推荐答案

您可以在此处阅读该流程的分步教程:

You can read a step-by-step tutorial of the process here:

iPhone本地化教程

以下是基础知识的高级概述(上述教程)有详细信息):

Here's a high-level overview of the basics (the above tutorial has details):

1)更改所有要编码的编码字符串: NSLocalizedString(@我的文本,@翻译的上下文 )

1) Change all your coded strings to call: NSLocalizedString(@"My text", @"Context for the translator")

2)使用<$导出所有字符串c $ c> genstrings 终端命令。

3)这将创建一个名为Localizable.strings的文本文件,其中包含所有英文(源)字符串。它看起来像这样:

3) This creates a text file called Localizable.strings with all your English (source) strings. It looks like this:

/* Context for the translator */
"My text" = "My text";

您将该文件发送给翻译人员。他们会像这样翻译右边:我的文字=Mi texto;

You send that file to the translators. They'll translate the right side like this: "My text" = "Mi texto";

4)您将每个已翻译的Localizable.strings文件放在其正确的语言文件夹中: en.lproj fr.lproj es.lproj

4) You place each translated Localizable.strings file in its proper language folder: en.lproj, fr.lproj, es.lproj, etc.

当您的应用加载到iPhone上时,它会检查用户的语言设置。如果用户选择法语作为系统语言,则会加载 fr.lproj 文件夹文件中的 Localizable.strings 。如果有任何未翻译的字符串,则默认为英语(或任何源语言)。

When your app loads on the iPhone it will check the user's language settings. If the user has chosen French as the system language, the Localizable.strings inside your fr.lproj folder file will load. If there are any untranslated strings, it just defaults to English (or whatever your source language is) for those.

值得关注整个教程并注意文件/文件夹名称必须准确!

It's worth following the whole tutorial and note that the file/folder names have to be exact!

这篇关于iPhone应用程序的国际化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆