如何让 Cocoa 明白我的 iPhone 应用程序不是英文的?

发布于 2024-12-01 16:02:25 字数 327 浏览 0 评论 0原文

我正在开发一款纯瑞典语的 iPhone 应用程序,它永远不会本地化为任何其他语言。应用中的所有字符串都是瑞典语,因此我们甚至没有 Localized.strings

问题是 Cocoa 生成的字符串(例如 Done 和 Edit)是英文的。我尝试将 Info.plist 中的本地化本机开发区域设置为瑞典语,但这没有任何改变。告诉 Cocoa 我的应用程序是瑞典语的,这应该不难,但显然确实如此。

我还尝试了很多其他的东西,但没有任何运气。那么我需要做什么才能让 Cocoa 将其字符串本地化为瑞典语?

I work on an iPhone app that is purely in Swedish and it will never be localized to any other languages. All the strings in the app is in Swedish, so we don't even have Localizable.strings.

The problem is that the strings generated by Cocoa (such as Done and Edit) are in English. I've tried setting Localization native development region in the Info.plist to Swedish, but that changed nothing. It shouldn't be harder than that to tell Cocoa that my app is in Swedish, but obviously it is.

I've also tried a bunch of other stuff without any luck. So what do I need to do to make Cocoa localize its strings to Swedish?

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

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

发布评论

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

评论(3

醉生梦死 2024-12-08 16:02:25

Cocoa 生成的字符串(例如 Done 和 Edit)是英文的,因为您的 iPhone 语言设置设置为英语(在“设置”->“常规”->“国际”->“语言”)。如果您将语言设置设置为瑞典语,您应该会看到瑞典语文本。

这就是 iPhone 默认的工作方式,如果您想更改某些按钮的文本以强制它们为瑞典语,您将必须创建它们的出口并手动更改文本。例如像这样的 UIBarButtonItem (带有默认文本 Done (英文)):

UIBarButtonItem *doneButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneContact)] autorelease];
doneButton.title =@"Whatever";
self.navigationItem.rightBarButtonItem = doneButton;

我希望这可以帮助您......

The strings generated by Cocoa (such as Done and Edit) are in English because your iPhone language settings are set to English (in Settings -> General -> International -> Language ). If you set the language settings to Swedish you should see the texts in Swedish.

This is how the iPhone works by default, if you want to change the texts of some buttons to force them to Swedish you will have to create an outlet of them and change the text manually. For example like this UIBarButtonItem (with a default text Done (in english)):

UIBarButtonItem *doneButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneContact)] autorelease];
doneButton.title =@"Whatever";
self.navigationItem.rightBarButtonItem = doneButton;

I hope that this may help you...

天邊彩虹 2024-12-08 16:02:25

来自 CFBundle 文档:

kCFBundleDevelopmentRegionKey 的开发语言名称
捆绑。当 CFBundle 查找资源时,后备方法是查找
在名称由 kCFBundleDevelopmentRegionKey 指定的 lproj 中
在 Info.plist 文件中。因此,您必须确保捆绑包
包含一个具有该确切名称的 lproj,其中包含每个的副本
本地化资源,否则CFBundle无法保证回退
机制将发挥作用。适用于 iOS 2.0 及更高版本。宣布于
CFBundle.h。

我想说:你应该启用本地化,准备 swedish.lproj 并删除英语?

顺便说一句,完成&编辑应自动调整为当前活动语言。不是吗??

From the CFBundle documentation:

kCFBundleDevelopmentRegionKey The name of the development language of
the bundle. When CFBundle looks for resources, the fallback is to look
in the lproj whose name is given by the kCFBundleDevelopmentRegionKey
in the Info.plist file. You must, therefore, ensure that a bundle
contains an lproj with that exact name containing a copy of every
localized resource, otherwise CFBundle cannot guarantee the fallback
mechanism will work. Available in iOS 2.0 and later. Declared in
CFBundle.h.

I would say: you should enable localizations, prepare swedish.lproj and remove English perhaps?

btw, Done & Edit shall automatically adjusted to currently active language. isn't it??

前事休说 2024-12-08 16:02:25

您可能必须从 XIB 中提取所有字符串并翻译它(至少这是一个一次性过程),然后重新更新 XIB。以下命令行可以帮助您做到这一点。

ibtool --generate-strings-file out.strings yourWindow.xib

// Update the out.strings with your language translation

ibtool --strings-file out.strings yourWindow.xib --write yourWindow.xib

you might have to do use extract all strings from the XIB and translate it (at least it is a one time process) and then reupdate the XIB. The following command line can help you do that.

ibtool --generate-strings-file out.strings yourWindow.xib

// Update the out.strings with your language translation

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