问题当串联字符串和资源价值 [英] Problem when concatenating string and a resource value

查看:116
本文介绍了问题当串联字符串和资源价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的.aspx页面中一个奇怪的现象。我在一些国际化的页面,但我想仅保留我的资源实体或值对象我想有一个关键值,如:

I'm having a strange behavior in my .aspx page. I'm internationalizing some pages, but as I want to keep only entities or value object in my resource I want to have a key-value like:

(pt-br)
    CITY - Cidade
    STATE - Estado
    ...

但是,当我列出的实体,我想提出的:在末尾。这样的:

But when I list the entities, I want to put the " : " at end. Like:

<asp:Label ID="LabelCity" runat="server" Text="<%$ Resources:Localizacao, CITY %>:"></asp:Label>

但是,如果我把:在文本属性的资源后,该页面只显示:

But, if I put the " : " after the resource in text property, the page only shows " : ".

我的简单的解决办法是标签的所有定义后放,但我认为这也错了:

My simple solution is put after all definition of label, but I think this too wrong:

<asp:Label ID="LabelCity" runat="server" Text="<%$ Resources:Localizacao, CITY %>"></asp:Label>:

建议?

推荐答案

您正确地命名为:串联。问题是,串联是最严重的(如在高严重性)国际化的缺陷之一。
而不是做你做什么,我会建议你把整个字符串(或与占位符最坏的情况下字符串)到资源文件,即使你要复制的资源(这些复制的资源可能会以不同的方式取决于语境翻译)。

You named this correctly: the concatenation. The problem is, Concatenation is one of the most serious (as in high severity) i18n defect. Instead of doing what you do, I would advise you to put whole strings (or in the worst case scenario strings with placeholders) into resource files, even you have to duplicate resources (these duplicated resources might be translated in different way depending on a context).

让我给你举一个例子:回来时,我在本地化团队,我们与多个页面的控制台,每个页面有一个标题这是有事的政策,即防火墙<强>策略,防病毒和防间谍软件的政策。有人认为这是一个好主意,以节省一些precious位,只是会连接起来的题联:

Let me give you an example: back when I was in L10n Team, we had a console with multiple pages, each page had a title which was "Something Policy", i.e. "Firewall Policy", "Antivirus and Antispyware Policy". Somebody thought it is a good idea to save some precious bits and simply concatenated the title together:

String title = Resources.getString("Firewall") + "<b>" + Resources.getString("Policy") + "</b>";

我们唯一的问题是正确的波兰语翻译听起来像 Polityka zapory ogniowej,也就是政策是第一位的。在现实中,我们有它翻译成Zapora ogniowa Polityka ,这是无处正确的翻译附近(通知防火墙的翻译应该是所有格...翻译根本不知道他是什么翻译,因此,翻译,而且它可能无法修复,因为我们无法重新排序的句子。

The only problem we had is correct Polish translation sounds like "Polityka zapory ogniowej", that is "Policy" comes first. In reality, we had it translated as "Zapora ogniowa Polityka" which is nowhere near the correct translation (notice that translation of "Firewall" should be genitive... Translator had no clue what he is translating, thus the translation. And it couldn't be fixed as we were unable to re-order the sentence.

所需的修复外部化整个字符串,所以实际上所有原始开发商的良好愿望去铺平了地狱。

The fix required externalizing the whole string, so actually all the good intentions of original developer went to pave the hell.

如果你还在读这些文字,请记住,在法语所有冒号必须是空间pceded $ P $(这只是他们的规则)。为了建立多个句子可能会禁止该重新使用相同的翻译...

If you still reading this, please keep in mind, that all colons in French language must be preceded by space (that's just their rule). Re-using the same translations in order to build multiple sentences might disallow that...

这篇关于问题当串联字符串和资源价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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