仅使用JmsI18NBundle从/ app / Resources / views进行翻译

时间:2016-06-08 00:17:58

标签: symfony internationalization

我尝试使用/ app / Resources / views中分配的模板生成带有jms_i18n_routing的转换文件.xliff。如果可能,我只想采取一个名为" frontend.html.twig"

的树枝

我使用下一个命令,但是只生成来自特定包的翻译,但不翻译任何模板保留在包目录之外,例如,文件" app / Resources / views / frontend.html.twig&# 34;未翻译:

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

谢谢!

1 个答案:

答案 0 :(得分:1)

我建议翻译文本使用JMSTranslationBundle。仅使用JmsI18NBundle转换路由。

从特定目录生成翻译文件' app /'

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

从特定文件名生成翻译文件:

  1. 将配置添加到jms_translation
  2. # 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]
    
    1. 执行以下命令:
    2. $ php app/console translation:extract en_US --config=custom_exclude_from_app --output-format=xliff --dir=app