Download the PHP package topview-digital/laravel-translation-helper without Composer
On this page you can find all versions of the php package topview-digital/laravel-translation-helper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download topview-digital/laravel-translation-helper
More information about topview-digital/laravel-translation-helper
Files in topview-digital/laravel-translation-helper
Package laravel-translation-helper
Short Description Laravel Translation Helper
License MIT
Informations about the package laravel-translation-helper
Laravel Translation Helper
Localize the terms in your code and store translations in the tables or export to text files.
Implementations of inline translation for your strings required localization and archiving the translations int tables or exporting to text files, while you have google access and queue function enabled for default queue, it will help you to generate the other required languages automatically via google translation.
Requirements
- PHP >= 7.0
- MySQL >= 5.7
- Laravel >= 5.5
Installation
Require the package via Composer:
Laravel will automatically register the ServiceProvider.
Publish Package
After installation, please publish the assets by below commands
Configure Package
Please config your settings in config/trans-helper.php file, it should looks like below
Once you confired your settings, you may run install command to setup the tables for the package.
Configure Queue
If you want use the auto translation feature, please also config your queue config file and .env file. If you have enabled the queue feature for default queue, please skipp below instructions. config/queue.php[example]
.env[queue section]
After your configuration done, please ensure the your queue is up and running. Simple way is run
and make it running all the time in the background.
Mark the Cited Code Feature
You could follow up on the translation later by setup the web interface to fine-tuning the interpretations. However, sometimes it's difficult to recall where the terms are used. You can turn on the feature of cite, and it will help you to record the place you cited the term in your code.
Define Your Own Translator
You can define your own translator by reference the code below, and set it in config.
Usage
For the following examples
Translation
You can wrap your strings, NO parameters invovled, in helper function localize()
And the helper will translate the string into relavent languages accroding to your current locale of laravel user while you have laravel queue function enabled and queue default is running in background.
Sweep
As the process of development the strings in the code changes a lot, you may manually run command
or call the sweep action in your code by helper function sweep()
And you also can manually trigger the auto translation without/before running your code by calling command
or call the translation in your code by calling helper function translate($locales=[]), the inbound parameter is the locale codes you want to translate like ['en','zh-CN','br','de'...], default locales are the config('app.locale'), config('app.fallback_locale'), config('app.faker_locale').
Export
You can use the translation feature without text lang files, you really need them. You can use export command to get them
or call it in your code or tinker enviroment by helper command export($path=null,$locales=null), it will help your to export all locales that has translated in the tables or the locales that your assigned. Noticed: if the locale that you assigned not have any tranlsations yet, it will use the translations of locale config('app.locale').
The export language files will named with the helper function localize() called file namespace.
Hope you enjoy it! Thanks!
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-translation-helper with dependencies
laravel/framework Version ^5.5.0
campo/random-user-agent Version ^1.3
stichoza/google-translate-php Version ^4.0