Before you start, make sure you have an active license key. You can purchase a license here.
Next, add the private repository to your composer.json
file:
1"repositories": [2 {3 "type": "composer",4 "url": "https://laratranslate.composer.sh"5 }6]
Now, you can install the package using Composer:
1composer require elegantly/laratranslate --dev
Use your email as the username and your license key as the password.
Finally, publish the necessary assets with the following command:
1php artisan laratranslate:upgrade
To ensure the new assets are automatically published whenever the package is updated, add this command
to your composer.json
scripts:
1{2 "scripts": {3 "post-update-cmd": [4 "@php artisan laratranslate:upgrade",5 ]6 }7}
If you're not using laratranslate
in production (which is not recommended), add the
following lines to your .gitignore
file:
1.translator.cache2/public/vendor/laratranslate
By default, the Laratranslate UI is accessible at /laratranslate
. You can customize this in
the config file.
The package should work seamlessly with both PHP
and JSON
files, including
files nested in subdirectories such as /spark/en.json
or
vendor/package-name/fr.json
.
If you store your translation strings in a database or use a different method, you can still use this package!
You will need to create a custom driver by extending Elegantly\Translator\Drivers\Driver
.
This allows Laratranslate to understand how to edit your translations.
You can also publish the config file by running:
1php artisan vendor:publish --tag="laratranslate-config"
Laratranslate is built on elegantly/laravel-translator
, another package I've created. Its
documentation is relevant and can be found on GitHub.
To configure features like 'AI Translation' and 'AI Proofread', you need to publish the configuration
file for elegantly/laravel-translator
using the following command:
1php artisan vendor:publish --tag="translator-config"
For setting up OpenAI, DeepL, and other services, refer to the elegantly/laravel-translator documentation.
You can customize the prompts for both the 'AI Translation' and 'AI Proofread' features in the
elegantly/laravel-translator
configuration file.
If you think the default prompts should be different, feel free to suggest changes!
By default, this package will attempt to determine the locales defined in your application by scanning
your lang
directory.
You can configure the locales in either the laratranslate
or
elegantly/laravel-translator
configuration file like this:
1return [2 // ...3 'locales' => ['en', 'fr', 'es'],4 // ...5];