alessandrobelli / lingua
Translation Manager for Laravel, built with TALL stack.
Requires
- php: ^8.1
- illuminate/contracts: ^9.0
- spatie/laravel-package-tools: ^1.13.0
Requires (Dev)
- laravel/legacy-factories: ^1.3
- laravel/pint: ^1.0
- livewire/livewire: 2.*
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
- spatie/laravel-ray: ^1.26
README
👅 Lingua
Translation Manager for Laravel, built with TALL stack.
🇮🇹 From Italian: Lingua means both Tongue and Language
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.
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 and Freek to have taught me how to develop packages.
Requirements
- Install AlpineJS and include it in your JS file.
- Install Livewire.
- Then you can install the package via composer.
Installation
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:
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.
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:
<script> 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 "[]"; } ?>; </script>
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:
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.
More
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email info@alessandrobelli.it instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.