https://github.com/backstagephp/laravel-translations
A Laravel Translations package. Also works well with our Filament Translations package:
https://github.com/backstagephp/laravel-translations
Last synced: 10 months ago
JSON representation
A Laravel Translations package. Also works well with our Filament Translations package:
- Host: GitHub
- URL: https://github.com/backstagephp/laravel-translations
- Owner: backstagephp
- License: mit
- Created: 2025-01-14T16:39:25.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-07T12:46:14.000Z (10 months ago)
- Last Synced: 2025-04-07T13:38:38.922Z (10 months ago)
- Language: PHP
- Homepage: https://github.com/vormkracht10/filament-translations
- Size: 175 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel Translations package
[](https://packagist.org/packages/backstage/laravel-translations)
[](https://github.com/backstagephp/laravel-translations/actions?query=workflow%3Arun-tests+branch%3Amain)
[](https://github.com/backstagephp/laravel-translations/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[](https://packagist.org/packages/backstage/laravel-translations)
## Nice to meet you, we're [Vormkracht10](https://vormrkacht10.nl)
Hi! We are a web development agency from Nijmegen in the Netherlands and we use Laravel for everything: advanced websites with a lot of bells and whitles and large web applications.
## Installation
You can install the package via composer:
```bash
composer require backstage/laravel-translations
```
You can publish and run the migrations with:
```bash
php artisan vendor:publish --provider="Backstage\Translations\Laravel\TranslationServiceProvider"
php artisan migrate
```
This is the contents of the published config file:
```php
use EchoLabs\Prism\Enums\Provider;
[
'scan' => [
'paths' => [
base_path(),
],
'files' => [
'*.php',
'*.blade.php',
'*.json',
],
'functions' => [
'trans',
'trans_choice',
'Lang::transChoice',
'Lang::trans',
'Lang::get',
'Lang::choice',
'@lang',
'@choice',
'__',
],
],
'translators' => [
'default' => env('TRANSLATION_DRIVER', 'google-translate'),
'drivers' => [
'google-translate' => [
// no options
],
'ai' => [
'provider' => Provider::OpenAI, // Example provider
'model' => 'text-davinci-003', // Example model
'system_prompt' => 'You are an expert mathematician who explains concepts simply. The only thing you do it output what i ask. No comments, no extra information. Just the answer.', // Example system prompt
],
],
],
];
```
If you have choosen the AI driver, please read the [Prism documentation](https://prism.echolabs.dev/providers/anthropic.html) on how to configure providers.
## Usage
### Add lang types
If you want to add a language use the following command:
```bash
php artisan translations:languages:add {locale} {label}
```
For example:
```bash
php artisan translations:languages:add nl Nederlands
translations:languages:add en English
translations:languages:add fr-BE Français // French specifically for Belgians
```
The command can also be used without in-command-line parameters
### Scan for translations
To scan for translations within your Laravel application, use the following command:
```bash
php artisan translations:scan
```
### Translate scanned translations
To translate the scanned translations, use the following command:
```bash
php artisan translations:translate
{--all : Translate language strings for all languages}
{--code= : Translate language strings for a specific language}
{--update : Update and overwrite existing translations}
```
For example:
```bash
php artisan translations:translate --code=nl
php artisan translations:translate --code=en
php artisan translations:translate --code=fr-BE --update // overwrite existing translations
php artisan translations:translate // translate all languages
```
## Testing
```bash
composer test
```
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
## Security Vulnerabilities
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
## Credits
- [Manoj Hortulanus](https://github.com/arduinomaster22)
- [Mark van Eijk](https://github.com/markvaneijk)
- [All Contributors](../../contributors)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.