yusufonur / laravel-localization
Laravel localization
1.1.1
2020-12-07 06:47 UTC
Requires
- php: ^8.0
- illuminate/auth: ^8.0
- illuminate/container: ^8.0
- illuminate/contracts: ^8.0
- illuminate/database: ^8.0
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.3
- predis/predis: ^1.1
README
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.