GitHub - ben182/laravel-auto-translate: Automatically translate your language fi...
source link: https://github.com/ben182/laravel-auto-translate
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
README.md
Laravel Auto Translate
With this package you can translate your language files using a translator service. Currently the package ships only with Google Translate.
Specify a source language and a target language and it will automatically translate your files. This is useful if you want to prototype something quickly or just a first idea of the translation for later editing. The package ships with two artisan commands. One for translating all the missing translations that are set in the source language but not in the target language. The other one for translating all source language files and overwriting everything in the target language.
Installation
This package can be used in Laravel 5.6 or higher.
You can install the package via composer:
composer require ben182/laravel-auto-translate
Config
After installation publish the config file:
php artisan vendor:publish --provider="Ben182\AutoTranslate\AutoTranslateServiceProvider"
You can specify your source language, the target language(s), the translator and the path to your language files in there.
Usage
Missing translations
Simply call the artisan missing command for translating all the translations that are set in your source language, but not in your target language:
php artisan autotrans:missing
E.g. you have English set as your source language. The source language has translations in auth.php:
<?php return [ 'failed' => 'These credentials do not match our records.', 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', ];
Your target language is German. The auth.php file has the following translations:
<?php return [ 'failed' => 'Diese Kombination aus Zugangsdaten wurde nicht in unserer Datenbank gefunden.', ];
The artisan missing command will then translate the missing auth.throttle
key.
All translations
To overwrite all your existing target language keys with the translation of the source language simply call:
php artisan autotrans:all
This will overwrite every single key with a translation of the equivalent source language key.
Extending
You can create your own translator by creating a class that implements \Ben182\AutoTranslate\Translators\TranslatorInterface
. Simply reference it in your config file.
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK