您能以编程方式访问Cocoa Touch中的标准本地化字符串吗? [英] Can you programmatically get access to the standard localised strings in Cocoa Touch?

查看:80
本文介绍了您能以编程方式访问Cocoa Touch中的标准本地化字符串吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

某些iOS控件具有Apple内置的本地化字符串。 完成,编辑,返回栏按钮项是一些示例。有没有办法访问这些字符串?

Some iOS controls have localised strings built in by Apple. The "Done", "Edit", "Back" bar button items are some examples. Is there a way to access these strings?

我正在制作一个带有标准删除或取消选项的UIActionSheet,就像删除联系人中的联系人一样app。

I am making a UIActionSheet with standard "Delete" or "Cancel" options, just like when you delete a contact in the Contacts app.

有没有办法在代码中引用这些字符串?如果没有,是否有某些地方我至少可以获得这些字符串(比如从Apple应用程序的资源中提取它们)?它可以节省额外的本地化工作,并确保与平台的一致性。

Is there a way to reference these strings in code? If not, is there somewhere I can at least get these strings (like extracting them from the resources of an Apple app)? It would save extra localisation work and would ensure consistency with the platform.

推荐答案

如果iOS与Mac OS一样,每个应用程序都有自己的应用程序Localizable.strings文件。
在每个字符串文件中,您拥有所有那些小字符串,如完成,编辑,取消等。

If iOS is like Mac OS each app carries their own Localizable.strings file. And in each strings file you have all those little strings like Done, Edit, Cancel and so on.

这些是我从Finder.app的英文Localizable.string文件中复制的一些字符串:

These are some strings I copied from the English Localizable.string file from Finder.app:

<key>AL1</key>
<string>Cancel</string>
<key>AL4</key>
<string>OK</string>
<key>AL9</key>
<string>Don’t Save</string>
<key>FF24</key>
<string>Save</string>
<key>U32</key>
<string>Yes</string>
<key>U33</key>
<string>No</string>

你明白了。每个小字符串都在每个应用程序中本地化

You get the idea. Each little string is localized in each app.

这个来自iTunes.app。

This one is from iTunes.app.

/* ===== Ask User Strings ===== */
"23987.001" = "Yes";
"23987.002" = "No";
"23987.003" = "OK";
"23987.004" = "Cancel";
"23987.005" = "Ignore";
"23987.006" = "Quit";
"23987.007" = "Don’t Quit";
"23987.008" = "Apply";
"23987.009" = "Don’t Apply";
"23987.010" = "Later";
"23987.011" = "Don’t Save";
"23987.012" = "Save";
"23987.013" = "Stop";
"23987.014" = "Continue";
"23987.015" = "Delete";
"23987.016" = "Remove";
"23987.017" = "Replace";
"23987.018" = "Don’t Replace";
"23987.019" = "Do not ask me again";

看起来更有条理。但是可能不允许复制他们的文件; - )

Looks a little bit more structured. Copying their files is probably not allowed though ;-)

An answer in apples devforum by Quinn (eskimo1) from Apple Developer Relations.


有些UI元素会自动为您本地化。例如,UIBarButtonItem上的图稿。 但是,在UIActionSheet中使用OK和取消这些字符串是不受支持的。但是,对于您的本地人来说,它们应该是微不足道的。

Some UI elements are automatically localised for you. For example, the artwork on a UIBarButtonItem. However, there's no supported way to get to the strings like "OK" and "Cancel" as they are used in a UIActionSheet. They should, however, be trivial for your localiser to cope with.

虽然2岁。但是较新的线程具有相同的结果。无法获得这些字符串。

2 years old though. But newer threads have the same outcome. No way to get those strings.

这篇关于您能以编程方式访问Cocoa Touch中的标准本地化字符串吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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