laravel-localization maintained by yusufonur
Description
Laravel localization
Author
Last update
2020/12/07 14:34
(dev-master)
License
Downloads
11
Tags
Laravel localization
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.
Requirements
- PHP 8,
- Laravel 6, 7, 8 latest version,
- Redis or TaggableStore driver for cache.
Installation
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"
Usage
$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"
}
}
*/
Helper Usage
{{ __local("home") }}
If default language (you can get with app()->getLocale()) then result is tr: "Anasayfa"
If getLocale then result is en: "Home"
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.