我已经开始在 Symfony2 中使用翻译系统。
一切都很好。
但是,在从树枝视图文件中引用源/目标字符串时,我有一个关于最佳实践的问题。
鉴于这种:
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="file.ext">
<body>
<trans-unit id="1">
<source>Short String</source>
<target>Short String</target>
</trans-unit>
<trans-unit id="2">
<source>Some really long string for example a paragraph about some random thing that is likely to change in the future</source>
<target>Some really long string for example a paragraph about some random thing that is likely to change in the future</target>
</trans-unit>
</body>
</file>
</xliff>
使用类似没有问题:
{% trans_default_domain 'messages' %}
<h3>{{ 'Multicoin Cryptocurrency Online Wallet' | trans }}</h3>
<p>{{ 'Some really long string for example a paragraph about some random thing that is likely to change in the future' | trans }}</p>
我知道您可以在源代码部分使用简短的源代码引用,例如:
<trans-unit id="2">
<source>page.long.paragraph</source>
<target>Some really long string for example a paragraph about some random thing that is likely to change in the future</target>
</trans-unit>
这使树枝部分更清洁:
{% trans_default_domain 'messages' %}
<h3>{{ 'Multicoin Cryptocurrency Online Wallet' | trans }}</h3>
<p>{{ 'page.long.paragraph' | trans }}</p>
问题是,如果我想将原始的 en 翻译文件提供给翻译人员以翻译成另一种语言,那么在现场翻译需要翻译的整个字符串会好得多。然而,这使得树枝代码相当凌乱。是否有另一种方法来引用 twig 中的翻译字符串而不必使用整个源字符串?