Localization

Localization

URL Localization - (ccTLD, sub-domain, sub-directory).

Moamen Eltouny (Raggi)
PHP Version : >= 7.2 Laravel Version : >= 6.0 License Support
Source Packagist Version Packagist Downloads

Afrikaans Akan shqip አማርኛ العربية հայերեն অসমীয়া azərbaycan Азәрбајҹан bamanakan euskara беларуская বাংলা босански bosanski brezhoneg български ဗမာ català 中文 简体中文 繁体中文 kernewek hrvatski čeština dansk Nederlands རྫོང་ཁ English Esperanto eesti eʋegbe føroyskt suomi français Pulaar galego Luganda ქართული Deutsch Ελληνικά ગુજરાતી Hausa עברית हिन्दी magyar íslenska Igbo Bahasa Indonesia Gaeilge italiano 日本語 kalaallisut ಕನ್ನಡ کٲشُر қазақ тілі ខ្មែរ Gikuyu Kinyarwanda 한국어 кыргызча ລາວ latviešu lingála lietuvių Tshiluba Lëtzebuergesch македонски Malagasy Bahasa Melayu മലയാളം Malti Gaelg मराठी монгол नेपाली isiNdebele davvisámegiella norsk norsk bokmål nynorsk ଓଡ଼ିଆ Oromoo ирон پښتو فارسی polski português پنجابی ਪੰਜਾਬੀ Runasimi română rumantsch Ikirundi русский Sängö Gàidhlig српски srpski Srpskohrvatski chiShona ꆈꌠꉙ සිංහල slovenčina slovenščina Soomaali español Kiswahili svenska Tagalog தமிழ் తెలుగు ไทย བོད་སྐད་ ትግርኛ lea fakatonga Türkçe українська اردو ئۇيغۇرچە oʻzbekcha Tiếng Việt Cymraeg West-Frysk ייִדיש Èdè Yorùbá isiZulu
Install

Install the latest version using Composer

composer require pharaonic/laravel-localization
php artisan migrate

OptionalPublish the config file.

php artisan vendor:publish --tag=laravel-localization
Usage

Simple and easy routing.

You can change the routing type in config file.

Route::localized(function(){
    Route::get('/page', function(){

        return 'Pharaonic';
    });
});

// Examples :
// domain.com/ar/page        sub-directory
// ar.domain.com/page        sub-domain
// domain.com.eg/page        ccTLD
Helpers

Simple helpers to use Localization easily.

locale()->current                       // Getting current locale.
locale()->default                       // Getting default locale.
locale()->supported                     // Getting supported locales list.

locale()->isSupportedLocale('en')       // Checking if locale has been supported.
locale()->isSupportedccTLD('eg')        // Checking if ccTLD has been supported.

locale()->setLocale('ar')               // Setting a locale manually.

locale()->getName()                     // Getting current locale name.
locale()->getNativeName()               // Getting current locale native name.
locale()->getLanguage()                 // Getting current language code.
locale()->getRegion()                   // Getting current region code if exists.
locale()->getDirection()                // Getting current locale direction (rtl, ltr).
locale()->isRTL()                       // Checking if locale is rtl direction.

locale()->locale()->route('home')                 // Getting localized url with the current locale.
locale('en')->locale()->route('home')             // Getting localized url with specified locale.
locale()->unLocalizedlocale()->route('home')      // Getting un-localized url.
URL Marco

Getting localized temporary signed route.

use Carbon\Carbon;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\URL;

// Example : Localized Verification URL.

$url = URL::temporaryLocalizedSignedRoute(
    'en',
    'verification.verify',
    Carbon::now()->addMinutes(Config::get('auth.verification.expire', 60)),
    [
        'id' => 1,
        'hash' => sha1('raggi@raggitech.com'),
    ]
)