BlackBerry - 对中文的语言支持

发布于 2024-12-27 19:11:02 字数 822 浏览 4 评论 0原文

我通过添加各种欧洲语言/方言的正确资源文件来本地化我的应用程序。

我的项目中有所需的文件夹: ./res/com/demo/localization

它包含所需的文件,例如 Demo.rr、Demo.rrc、Demo_de.rrc 等。

我想添加对 2 种中文方言的支持,并且我有Excel 文件中的翻译。在 iPhone 上,它们由代码 zh_TWzh_TW 引用。 zh_CM。按照德语的模式,我创建了 2 个额外的文件,名为 Demo_zh_TW.rrc 和 Demo_zh_TW.rrc。 Demo_zh_CN.rrc。

我使用 Eclipse 的文本编辑器打开文件 Demo_zh_CN.rrc,并使用普通资源文件格式粘贴中文翻译行:

  • START_LOCATION#0="开始位置";

当我尝试保存文件时,我收到 Eclipse 关于 Cp1252 字符编码的错误:

保存无法完成。

原因: 某些字符无法使用“Cp1252”字符编码进行映射。 更改编码或删除不是的字符 “Cp1252”字符编码支持。

看起来Eclipse编辑器会接受中文字符,但是资源工具期望这些字符必须以Java Unicode /u编码保存在资源文件中。


如何添加对这 2 个区域的语言支持,而无需在每个字符串中手动复制粘贴?

是否有一个工具可以用来对 Excel 中的字符串进行 Java Unicode /u 编码,以便它们只能保存在代码页 1252 拉丁字符中?

I have localised my app by adding the correct resource files for various European languages / dialects.

I have the required folder in my project: ./res/com/demo/localization

It contains the required files e.g. Demo.rrh, Demo.rrc, Demo_de.rrc etc.

I want to add support for 2 Chinese dialects, and I have the translations in an Excel file. On iPhone, they are referred to by the codes zh_TW & zh_CM. Following the pattern with German, I created 2 extra files called Demo_zh_TW.rrc & Demo_zh_CN.rrc.

I opened file Demo_zh_CN.rrc using Eclipse's text editor, and pasted in line of the Chinese translation using the normal resource file format:

  • START_LOCATION#0="开始位置";

When I tried to save the file, I got Eclipse's error about the Cp1252 character encoding:

Save could not be completed.

Reason:
Some characters cannot be mapped using "Cp1252" character encoding.
Either change the encoding or remove the characters which are not
supported by the "Cp1252" character encoding.

It seems the Eclipse editor will accept the Chinese characters, but the resource tool expects that these characters must be saved in the resource file as Java Unicode /u encoding.


How do I add language support for these 2 regions without manually copy n pasting in each string?

Is there maybe a tool that I can use to Java Unicode /u encode the strings from Excel so they can be saved in Code page 1252 Latin chars only?

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

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

发布评论

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

评论(3

命比纸薄 2025-01-03 19:11:02

我不知道有任何现成的工具可以处理黑莓独特的本地化风格。

下面是一段 Java-SE 代码,我用来转换 BlackBerry 上使用的 UTF-8 字符串:

private static String unicodeEscape(String value, CharsetEncoder encoder) {
    StringBuilder sb = new StringBuilder();
    for(char c : value.toCharArray()) {
        if(encoder.canEncode(c)) {
            sb.append(c);
        } else {
            sb.append("\\u");
            sb.append(hex4(c));
        }
    }
    return sb.toString();
}

private static String hex4(char c) {
    String ret = Integer.toHexString(c);
    while(ret.length() < 4) {
        ret = "0" + ret;
    }
    return ret;
}

使用 Charset.forName("ISO-8859-1").newEncoder 使用 8859-1 编码器调用 unicodeEscape ()

I'm not aware of any readily available tools for working with BlackBerry's peculiar localization style.

Here's a snippet of Java-SE code I use to convert the UTF-8 strings I get for use with BlackBerry:

private static String unicodeEscape(String value, CharsetEncoder encoder) {
    StringBuilder sb = new StringBuilder();
    for(char c : value.toCharArray()) {
        if(encoder.canEncode(c)) {
            sb.append(c);
        } else {
            sb.append("\\u");
            sb.append(hex4(c));
        }
    }
    return sb.toString();
}

private static String hex4(char c) {
    String ret = Integer.toHexString(c);
    while(ret.length() < 4) {
        ret = "0" + ret;
    }
    return ret;
}

Call unicodeEscape with the 8859-1 encoder with Charset.forName("ISO-8859-1").newEncoder()

╭ゆ眷念 2025-01-03 19:11:02

我建议您查看 黑莓印地语和古吉拉特语文本显示

您需要使用资源编辑器使这些文件具有正确的编码。 Eclipse 会自动转义字符。

I suggest you look at Blackberry Hindi and Gujarati text display

You need to use the resource editor to make these files with the right encoding. Eclipse will escape the characters automatically.

乖乖公主 2025-01-03 19:11:02

这是您的资源文件的编码问题。 1252 代码页 仅包含拉丁字符。

我从未使用过 Eclipse,但应该在某个地方指定文件的编码,如果可能的话,应该将文件的默认编码设置为 UTF-8。这将处理你的中文字符。

您还可以使用一个好的编辑器,例如 Notepad++EMEditor 设置文件的编码。

请参阅此处了解如何将 Eclipse 配置为默认使用 UTF-8。

This is a problem with the encoding of your resource file. 1252 Code Page contains Latin characters only.

I have never worked with Eclipse, but there should be somewhere you specify the encoding of the file, you should set your default encoding for files to UTF-8 if possible. This will handle your chinese characters.

You could also use a good editor like Notepad++ or EMEditor to set the encoding of your file.

See here for how you can configure Eclipse to use UTF-8 by default.

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