greenhollowtech/ght-d-tools-bundle

3.0.2 2020-08-10 20:16 UTC

This package is auto-updated.

Last update: 2024-09-11 05:03:29 UTC


README

此软件包通过为默认选项配置简化了常见 Symfony 开发命令的运行,并添加了一些其他有用的选项和功能。

安装

获取 Composer 包

对于 Symfony 5 及以上版本

使用 Composer 安装,运行 composer require greenhollowtech/ght-d-tools-bundle

对于 Symfony 4 及以下版本

使用 Composer 安装 d-tools 版本 2,运行 composer require "greenhollowtech/ght-d-tools-bundle:2.*"

添加 GHTDevToolsBundle(如果您有 Symfony 3 应用程序)

// app/AppKernel.php

    public function registerBundles()
    {
        $bundles = array(
            // your normal bundles ...
        );

        if (strpos($this->getEnvironment(), 'dev') !== false) {
            $bundles = array_merge($bundles, array(
                new GHT\DevToolsBundle\GHTDevToolsBundle(),
                // other dev only bundles ...
            ));
        }

        return $bundles;
    }

配置

最小配置

d_tools:
    bundle: ExampleBundle

所有配置选项

d_tools:
    # The target bundle or directory
    bundle: ExampleBundle
    path: The bundle path when it cannot be guessed from the bundle
    translations_path: The translations path when it cannot be guessed from the path

    # The translation:update command, used by d:trans:refresh and d:trans:add
    translation_update:
        # If set, all other locales will not auto-generate new translation units
        primary_locale: ~
        # If both types of a conversion are true, defaults to the "as_char" conversion and the "as_entity" conversion is ignored
        conversions:
            # Should ampersand HTML entities be converted to characters
            amp_as_char: false
            # Should bare ampersands be converted to HTML entities (ignores ampersands in HTML entities)
            amp_as_entity: false
            # Should less than / greater than HTML entities be converted to characters
            ltgt_as_char: false
            # Should less than / greater than characters be converted to HTML entities
            ltgt_as_entity: false
            # Should non-breaking space HTML entities be converted to character
            nbsp_as_char: false
            # Should non-breaking space characters be converted to HTML entities
            nbsp_as_entity: false
        defaults:
            # All the locales to be updated at once
            locales: [ 'en' ]
            # Override the default prefix
            prefix: '__'
            # If set, no prefix is added to the translations
            no_prefix: false
            # Override the default output format
            output_format: 'xlf'
            # Should the messages be dumped in the console or should the update be done
            mode: 'force' # or 'dump-messages'
            # Should backup be disabled
            no_backup: false
            # Should clean not found messages
            clean: false
            # Specify the domain to update
            domain: ~

    # The d:trans:add command
    translation_add:
        defaults:
            # The translation domain
            domain: 'messages'
            # The translation locale
            locale: 'en'
            # The translation file format
            file_format: 'xlf'
            # Should the translation refresh be run after adding new translations
            refresh: false

用法

刷新翻译

翻译按字母顺序排序,CDATA 包裹发生,缺少的翻译将触发设置或默认前缀的提示。

bin/console d:trans:refresh

添加翻译

只需添加翻译标记。翻译文本将在下次刷新时提示。

bin/console d:trans:add -t trans.one -t trans.two

可以同时设置翻译文本。

bin/console d:trans:add -t trans.one:One -t trans.two:Two\ words -t "trans.three:This works too"

如果未将刷新配置为默认,则可以在刷新之前添加多种语言的翻译。

bin/console d:trans:add -t trans.hello:Hola -l es
bin/console d:trans:add -t trans.hello:Shalom -l he
bin/console d:trans:add -t trans.hello:Hello --refresh