Symfony2 の翻訳システムを使い始めました。
すべてが非常にうまく機能します。
ただし、twig ビュー ファイルからソース/ターゲット文字列を参照する場合のベスト プラクティスについて 1 つ質問があります。
これを考えると:
<?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 翻訳ファイルを翻訳者に渡して別の言語に翻訳させたい場合、翻訳する必要がある文字列全体を現場で持っている方がはるかに良いということです。しかし、それは小枝のコードをかなり乱雑にします。ソース文字列全体を使用せずに小枝で翻訳文字列を参照する別の方法はありますか?