davidrojo/sf-translations-helper

Symfony 的翻译文件助手

1.1.0 2016-11-24 10:36 UTC

This package is not auto-updated.

Last update: 2024-09-28 20:09:08 UTC


README

简单的命令来管理 Symfony 中的翻译。

这个包允许您将 yml 文件中的缺失翻译写入到请求缺失翻译的另一个文件中,并将其存储在输出文件中。

对于每个未找到的翻译,它将请求翻译,显示字段 ID 和要翻译的原始文本,这使得在添加字段时更新您的翻译文件变得非常容易。

** 目前仅支持 yml 翻译文件

内容

安装

只需用 composer 请求该包

composer.phar require davidrojo/sf-translations-helper

然后将其添加到 app/AppKernel.php

public function registerBundles()
    {
        $bundles = [
            ...
            new DavidRojo\SfTranslationHelper\SfTranslationsBundle(),
            ...
        ]
    }
}

用法

执行命令

php bin/console translations:helper [from_language] [to_language] [BundleName|File] [allowEmpty]

参数

from              Origin language file (example: en)
to                Destination language file (example: fr)
file              Bundle name or the full path from current folder to the input file
addEmpty          Optional (true/false), Add empty values to the destination 
                  file if no translation is added (default: false)

选项

--no-backup       If not present a .backup file will be generated if output file exists

示例

$ php bin/console translations:helper en fr AppBundle

Destination file already exists. Override? (y/n): y
Counting missing translations...3 missing, 0 empty

Field id: delete
Original: Eliminar
Please enter the translation: Effacer

Field id: courses.create
Original: Crear curso
Please enter the translation: Créer un cours

Field id: total
Original: Total
Please enter the translation: Total
Saving file.
File saved at /AppBundle//Resources/translations/messages.fr.yml

贡献

只需提出一个问题或发送一个 pull request,如果合适,它将被整合。

捐赠

如果您喜欢这个包并节省了一些时间,您可以

;)