This package helps you to use multiple languages in your projects. You can write languages and their word equivalents and use them in your application. I recommend using redis for better performance.
- PHP 8,
- Laravel 6, 7, 8 latest version,
- Redis or TaggableStore driver for cache.
You can install the package via composer:
composer require yusufonur/laravel-localization
You can publish and run the migrations with:
php artisan vendor:publish --provider="YusufOnur\LaravelLocalization\LaravelLocalizationServiceProvider" --tag="migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --provider="YusufOnur\LaravelLocalization\LaravelLocalizationServiceProvider" --tag="config"
$turkish = LaravelLocalization::createLanguage("Türkçe", "tr");
$english = LaravelLocalization::createLanguage("İngilizce", "en");
$metaHome = LaravelLocalization::createLanguageMeta("home");
$metaContact = LaravelLocalization::createLanguageMeta("Contact");
LaravelLocalization::createLanguageMetaTranslate($turkish, $metaHome, "Anasayfa");
LaravelLocalization::createLanguageMetaTranslate($turkish, $metaContact, "İletişim");
LaravelLocalization::createLanguageMetaTranslate($english, $metaHome, "Home");
LaravelLocalization::createLanguageMetaTranslate($english, $metaContact, "Contact");
return LaravelLocalization::getLanguageMetaTranslatesRegular();
/*
{
"en": {
"home": "Home",
"Contact": "Contact"
},
"tr": {
"home": "Anasayfa",
"Contact": "İletişim"
}
}
*/
{{ __local("home") }}
If default language (you can get with app()->getLocale()) then result is tr: "Anasayfa"
If getLocale then result is en: "Home"
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.