2016-06-08 25 views
1

我試圖從/ app/Resources/views中分配的模板生成帶有jms_i18n_routing的翻譯文件.xliff。如果可能的話,我想只使用一個名爲「frontend.html.twig」的樹枝只能從/ app/Resources/views用JmsI18NBundle翻譯

即時通訊使用下一個命令,但只生成來自特定包的翻譯,但不能翻譯任何留在包之外的模板例如目錄,文件 「應用/資源/視圖/ frontend.html.twig」 不譯:

php app/console translation:extract en --enable-extractor=jms_i18n_routing --bundle="AcmeFooBundle" 

謝謝!

回答

1

我建議翻譯文本使用JMSTranslationBundle。使用JmsI18NBundle只能翻譯路線。

從一個特定的目錄中生成翻譯文件的應用程序/':

$ php app/console translation:extract en_US --config=app --output-format=xliff --dir=app 

生成特定文件名的翻譯文件:

  1. 添加一個配置到jms_translation
# file: app/config/config.yml 
jms_translation: 
    source_language: "%locale%" 
    configs: 
     app: 
      dirs: [%kernel.root_dir%, %kernel.root_dir%/../src] 
      output_dir: %kernel.root_dir%/Resources/translations 
      ignored_domains: [routes] 
      excluded_names: ["*TestCase.php", "*Test.php", "*.php"] 
      excluded_dirs: [cache, data, logs] 
     custom_exclude_from_app: 
      dirs: [%kernel.root_dir%] 
      output_dir: %kernel.root_dir%/Resources/translations 
      ignored_domains: [routes] 
      excluded_names: ["*TestCase.php", "*Test.php", "*.php", "backend.html.twig", "email_template.html.twig", "another_template_excluded.html.twig"] 
      excluded_dirs: [cache, data, logs] 
  • 執行以下命令:
  • $ php app/console translation:extract en_US --config=custom_exclude_from_app --output-format=xliff --dir=app