bernskioldmedia / laravel-autotranslate
一个使用 DeepL 自动将应用程序的语言文件翻译成选定语言的 Laravel 扩展包。
1.1.0
2023-07-04 13:51 UTC
Requires
- php: ^8.1
- deeplcom/deepl-php: ^1.2
- illuminate/contracts: ^9.0|^10.0
- spatie/laravel-package-tools: ^1.13.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^6.0|^7.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0|^8.0
- pestphp/pest: ^1.21|^2.0
- pestphp/pest-plugin-laravel: ^1.1|^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5|^10.0
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2024-09-30 12:01:47 UTC
README
一个使用 DeepL 自动将应用程序的 JSON 语言文件翻译成选定语言的 Laravel 扩展包。
安装
您可以通过 composer 安装此包
composer require bernskioldmedia/laravel-autotranslate
您可以使用安装命令安装此包
php artisan autotranslate:install
您可以使用以下命令发布配置文件
php artisan vendor:publish --tag="laravel-autotranslate-config"
这是已发布配置文件的内容
return [ /** * The source language that your application language is in before translation. */ 'source_language' => 'en', /** * This is your DeepL API key. */ 'api_key' => env('AUTOTRANSLATE_DEEPL_KEY'), /** * DeepL supports settings for each language to translate to. * These are the default settings that will be applied * unless you override it for a specific language below. * * See the DeepL PHP SDK for more information: https://github.com/DeepLcom/deepl-php */ 'options' => [ // Choose the formality of the text. // This setting is only available for certain languages: https://github.com/DeepLcom/deepl-php#listing-available-languages // Available options: 'less', 'more', 'default', 'prefer_less', 'prefer_more' 'formality' => 'default', // Specify how input text should be split into sentences. // Available options: 'on', (default) 'off', 'nonewlines' 'split_sentences' => 'on', // Controls automatic-formatting-correction. // Set to true to prevent automatic-correction of formatting. 'preserve_formatting' => false, // Type of tags to parse before translation. // Available options: 'html', 'xml' 'tag_handling' => 'html', // The ID of the DeepL glossary to use. 'glossary' => null, ], 'language_options' => [ // 'de' => [ // 'formality' => 'less', // ], ], ];
用法
要翻译应用程序的语言文件,您可以使用 autotranslate:translate
命令
php artisan autotranslate:translate sv
语言参数是必需的,应与您应用程序语言文件夹中的语言路径相对应。
自动导出字符串
如果您想自动从应用程序导出字符串到语言文件,您可以使用 Laravel 可翻译字符串导出器 包。
测试
composer test
变更日志
有关最近更改的更多信息,请参阅 变更日志
鸣谢
许可证
MIT 许可证 (MIT)。有关更多信息,请参阅 许可证文件