hricer / sync-translations
同步所有翻译文件。
0.3.1
2023-11-01 14:27 UTC
Requires
- php: >=8.1.0
- deeplcom/deepl-php: ^1.5.0
- symfony/console: ^6.1
- symfony/yaml: ^6.1
README
根据一个地区文件同步所有翻译文件。这将确保所有翻译文件包含相同的键。
这允许开发者只管理一种语言。在将应用程序部署到生产环境之前,开发者将对其他语言执行同步操作。
用法
假设你修改了主地区文件,例如 messages.en.yaml
common: yes: Yes + no: No actions: close: Close - send: Send toast: save: 'Successfully saved.'
现在你需要通过 messages.en.yaml
(添加新行或删除旧行)来同步所有 messages.*.yaml
文件。在终端中输入
$ php bin/console translation:sync en --domain=messages
该命令将更新所有 messages.*.yaml
(排除 en)。
例如 message.cs.yaml
common: yes: Ano + no: No actions: close: Zavřít - send: Odeslat toast: save: 'Úspešně uloženo.'
你可以使用 --deepl
参数来自动翻译所有新行。
安装
步骤 1: 下载软件包
$ composer require hricer/sync-translations --dev
步骤 2: 注册包
// bundles.php return [ // ... Hricer\SyncTranslations\SyncTranslationsBundle::class => ['dev' => true], ];
没有 Symfony 包管理系统的环境
创建一个带有翻译:同步作为唯一命令的终端应用程序
// bin/translation.php use Symfony\Component\Console\Application; use Hricer\SyncTranslations\Command\SyncTranslationCommand; (new Application('translation/sync')) ->add(new SyncTranslationCommand()) ->getApplication() ->setDefaultCommand('translation:sync', true) ->run();