https://github.com/alessandrobelli/lingua
Laravel translation manager.
https://github.com/alessandrobelli/lingua
laravel livewire translation-management
Last synced: 5 months ago
JSON representation
Laravel translation manager.
- Host: GitHub
- URL: https://github.com/alessandrobelli/lingua
- Owner: alessandrobelli
- License: mit
- Created: 2020-10-15T16:20:47.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-03-15T08:51:10.000Z (over 1 year ago)
- Last Synced: 2025-06-09T23:51:48.069Z (5 months ago)
- Topics: laravel, livewire, translation-management
- Language: PHP
- Homepage:
- Size: 206 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Security: SECURITY.md
Awesome Lists containing this project
README

# :tongue: Lingua
## Translation Manager for Laravel, built with TALL stack.
_:it: From Italian: Lingua means both Tongue and Language_
[](https://packagist.org/packages/alessandrobelli/lingua)
[](https://packagist.org/packages/alessandrobelli/lingua)
[](https://packagist.org/packages/alessandrobelli/lingua)
Lingua is a dashboard that allows you to create, manage and import your translations for your project.
**This package is in pre-release with known issues. Please report them.**
```txt
The new Release - 0.3 - bring a lot of changes, mainly in the interface. Screenshots here still outdated.
```
I would like to warmly thank [Spatie](https://spatie.be/) and Freek to have taught me how to develop packages.
## Requirements
1. [Install AlpineJS](https://github.com/alpinejs/alpine) and include it in your JS file.
2. [Install Livewire](https://laravel-livewire.com/docs/2.x/installation).
3. Then you can install the package via composer.
## Installation
```bash
composer require alessandrobelli/lingua
```
This package needs a column called *linguaprojects* on the user table, as well as a table "translations".
You can publish and run the migrations with:
```bash
php artisan vendor:publish --provider="alessandrobelli\Lingua\LinguaServiceProvider" --tag="migrations"
php artisan migrate
```
## Usage
You need to add the routes to your web.php file.
```php
Route::lingua('desiredslug');
```
Then you can go to /desiredslug to see the dashboard.

To use the translation files for Javascript files place this into your header:
```Javascript
window.trans = [];
window.trans = <?php
if(File::exists(resource_path() . "/lang/" . App::getLocale() . '.json'))
{
$json_file = File::get(resource_path() . "/lang/" . App::getLocale() . '.json');
echo json_decode(json_encode($json_file, true));
}
else{
echo "[]";
}
?>;
```
Then make a prototype function in Javascript to detect the `trans()` function inside your Javascript files, or use this, in case you use Vuejs and Lodash:
```Javascript
Vue.prototype.trans = (key) => {
if (_.isUndefined(window.trans[key])) {
return key;
} else {
if (window.trans[key] === "") return key;
return window.trans[key];
}
};
```
The language shown will be according to the locale of the browser, or you can use [this tutorial which worked for me](https://www.ryanoun.com/coding-notes/laravel/set-and-store-locale-in-laravel-5-6-using-middleware/).
## More
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
## Security
If you discover any security related issues, please email info@alessandrobelli.it instead of using the issue tracker.
## Credits
- [Alessandro Belli](https://github.com/AlessandroBelli)
- [All Contributors](../../contributors)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.