可翻译的内容和 HTML 标签
我使用 Twig,我想让以下内容可翻译:
{% trans %}
You have actually <span class='messageNumber'>{{messageNumber}} message(s)</span> in your mailbox.
{% endtrans %}
但是当 POEdit 解析此可翻译内容并将其发送给翻译人员时,他们将看到 标签和属性。我可以做什么来避免这种情况?
我想过这样做:
{% messageNumberFormatted = "<span class='messageNumber'>"~messageNumber~"message(s)</span>" %}
{% trans %}
You have actually {{messageNumberFormatted}} in your mailbox.
{% endtrans %}
但这对译者来说是不是有点重,甚至是不好的做法?那样的话,他们连“消息”两个字都看不到。
I use Twig and I want to make the following content translatable :
{% trans %}
You have actually <span class='messageNumber'>{{messageNumber}} message(s)</span> in your mailbox.
{% endtrans %}
But when this translatable content will be parsed by POEdit and sent to translators, they will see the <span>
tags and attributes. What can I do to avoid this ?
I thought about doing this way :
{% messageNumberFormatted = "<span class='messageNumber'>"~messageNumber~"message(s)</span>" %}
{% trans %}
You have actually {{messageNumberFormatted}} in your mailbox.
{% endtrans %}
But isn't it a bit heavy or even bad practice for the translators ? In that case, they can't even see the word "message".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,您应该将 transchoice 与显式区间复数结合使用,像这样:
那么也许你可以使用 replace 来替换
{{
带有开始标记,}}
带有结束标记。我不知道你是否可以像这样直接链接或者是否必须使用 设置首先。
First, you should use transchoice with explicit interval pluralization, like this :
Then maybe you could use replace to replace
{{
with the opening tag, and}}
with the closing tag. I don't know whether you can directly chain like thisOr if you must store in a variable by using set first.
您可以使用
trans
twig filer 和代表您的句子的键。You can use the
trans
twig filer with keys representing your sentences.