iphone:如何使我的应用程序支持两种或多种语言?

发布于 2024-12-03 15:03:16 字数 94 浏览 0 评论 0原文

我的应用程序有英文版。我希望它也能运行法语文本。

我需要执行哪些步骤?或者我需要什么 API 或额外代码?

任何示例或教程都会对我有更多帮助。

I have my app with english version. I want it to run with french text also.

What steps I need to perform? or what API or extra code I will need?

Any examples or tutorial will help me more.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

记忆消瘦 2024-12-10 15:03:17

您需要为所有语言添加可本地化的字符串。您还需要添加 .lproj 以及您想要提供支持的每种语言的本地化文件。

希望这对您有帮助。

编辑:

我有一些对您有用的链接。

http://www.icanlocalize.com/site/tutorials/iphone -应用程序本地化指南/

http://adeem.me/blog /2009/05/09/tutorial-iphone-localization-in-xib-nib-files/

如何简化 iPhone 本地化?

http://www.raywenderlich.com/2876/how-to-localize-an-iphone-app-tutorial

我觉得最后一个来自 http://www.raywenderlich.com 是我推荐的最好的一个。

希望这对您有帮助。

谢谢

You need to add localizable strings for all the languages. And also you need to add the .lproj along with the localized file for each language you want to provide the support for.

Hope this helps you.

EDIT:

I have some of these links useful for you.

http://www.icanlocalize.com/site/tutorials/iphone-applications-localization-guide/

http://adeem.me/blog/2009/05/09/tutorial-iphone-localization-in-xib-nib-files/

How simplify iPhone localization?

http://www.raywenderlich.com/2876/how-to-localize-an-iphone-app-tutorial

I feel the last one which is from http://www.raywenderlich.com is the best one I would recommend.

Hope this helps you.

Thanks

梦醒时光 2024-12-10 15:03:17

这些教程对初学者来说很有用,但在开始之前您应该考虑以下几点:

  • 当 XIB 可能发生更改时,不建议您本地化 XIB 文件的“正常”本地化,因为您必须维护多个 XIB 文件(对于每种语言)将会有一个独立的 XIB)老实说,一段时间后这会变得很痛苦

  • 因此我建议(尽管一开始需要更多工作)以编程方式设置标签和按钮标题:

     mylabel.text = NSLocalizedString(@"text:", @"text:"); 
    
    [mybtn setTitle: NSLocalizedString(@"textbtn", @"textbtn") forState:UIControlStateNormal];
    
  • 然后使用: genstrings -o en.lproj *.m 来创建字符串文件,它将查找所有这些 NSLocalizedString 并在文件夹 en.lproj 中创建一个文件 Localizable.strings

如果您遵循此建议,它将会让您将来的生活变得更轻松 - 尽管它还不是真正 100% 舒适。如果您需要添加一个新的 NSLocalizedString (例如,因为您有一个新标签),您需要创建一个全新的文件 Localizes.strings。确保您有该文件的备份副本(其中包含翻译),否则它会被覆盖并丢失。我还没有找到一个好的解决方案如何构建要翻译的字符串...

ps 不再需要添加本地化的 XIB 文件.. 否则你最终会得到多个 XIB 文件,这是人们想要避免的首位...

The tutorials are good for starters but you should consider following points before you start:

  • "normal" localization where you localize XIB files is not really recommendable when the XIB might change, since you have to maintain multiple XIB files (for each language there will be a standalone XIB) Honestly this becomes a pain after a while

  • Therefore I suggest (even though it is more work at the beginning) to set the labels and button titles programmatically:

     mylabel.text = NSLocalizedString(@"text:", @"text:"); 
    
    [mybtn setTitle: NSLocalizedString(@"textbtn", @"textbtn") forState:UIControlStateNormal];
    
  • Then use: genstrings -o en.lproj *.m to create the strings file which will look for all those NSLocalizedString and create a file Localizable.strings in the folder en.lproj

If you follow this advice it will make live easier for you in the future - though it's not really 100% comfortable yet. If you need to add a new NSLocalizedString (eg because you have a new label) you need to create a completely new file Localizable.strings. Make sure you have a backup copy of this file where you have the translation, otherwise it gets overwritten and lost. I haven't yet come accross a good solution how to build up the strings to be translated...

ps there is no need to add localized XIB files anymore.. otherwise you end up having multiple XIB files which one wants to avoid in the first place...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文