Все хорошо описано тут.
Создадим сэмпл:
nano ./test.soy
Вот такого содержания:
{namespace test} /** * Test template * */ {template .test} <div>{msg desc=""}Some text 1{/msg}</div> {msg desc="some text 2"}Some text 2{/msg} {/template}
java -jar SoyMsgExtractor.jar --outputFile ru.xlf --targetLocaleString ru ./test.soy
Посмотрим что получилось:
nano ./ru.xlf
<?xml version=»1.0″ encoding=»UTF-8″?>
<xliff version=»1.2″ xmlns=»urn:oasis:names:tc:xliff:document:1.2″>
<file original=»SoyMsgBundle» datatype=»x-soy-msg-bundle» xml:space=»preserve» source-language=»en» target-language=»ru»>
<body>
<trans-unit id=»290279582580677189″ datatype=»html»>
<source>Some text 2</source>
<target/>
<note priority=»1″ from=»description»></note>
</trans-unit>
<trans-unit id=»2508530510519909152″ datatype=»html»>
<source>Some text 1</source>
<target/>
</trans-unit>
</body>
</file>
</xliff>
тэг <target/> по умолчанию пуст. Т.е. при локализации перевод подставляться не будет, а будет браться оригинальный текст, исправим это
<?xml version=»1.0″ encoding=»UTF-8″?>
<xliff version=»1.2″ xmlns=»urn:oasis:names:tc:xliff:document:1.2″>
<file original=»SoyMsgBundle» datatype=»x-soy-msg-bundle» xml:space=»preserve» source-language=»en» target-language=»ru»>
<body>
<trans-unit id=»290279582580677189″ datatype=»html»>
<source>Some text 2</source>
<target>Текст 2</target>
<note priority=»1″ from=»description»></note>
</trans-unit>
<trans-unit id=»2508530510519909152″ datatype=»html»>
<source>Some text 1</source>
<target>Текст 1</target>
</trans-unit>
</body>
</file>
</xliff>
Теперь соберем шаблон с нашей локализацией
java -jar ./SoyToJsSrcCompiler.jar --locales ru --messageFilePathFormat ./{LOCALE}.xlf --outputPathFormat '{INPUT_FILE_NAME_NO_EXT}_{LOCALE}.js' ./test.soy
Посмотрим, что получилось:
nano ./test_ru.js // This file was automatically generated from test.soy. // Please don't edit this file by hand. if (typeof test == 'undefined') { var test = {}; } test.test = function(opt_data, opt_ignored) { return '<div>Текст 1</div>Текст 2'; };