Skip to content
This repository has been archived by the owner on Aug 30, 2020. It is now read-only.

The package used to support multi locales in your application.

Notifications You must be signed in to change notification settings

Elnooronline/laravel-locales

Repository files navigation

This package has been deprecated. But worry not. You can use laraeast/laravel-locales

Laravel Multi Locales Package

The package used to support multi locales in your application.

Installation

  1. Install package

    composer require elnooronline/laravel-locales
  2. Edit config/app.php (Skip this step if you are using laravel 5.5+)

    service provider:

    Elnooronline\LaravelLocales\Providers\LocalesServiceProvider::class,

    class aliases:

    'Locales' => Elnooronline\LaravelLocales\Facades\Locales::class,
  3. Configure your custom locales:

    php artisan vendor:publish --tag="locales:config"
  4. Copy locales flags to public:

    php artisan vendor:publish --tag="locales:flags"

Usage

Locales selector dropdown:

<li class="dropdown">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
        <img src="{{ Locales::getFlag() }}">
        {{ Locales::getName() }}
    </a>
    <ul class="dropdown-menu">
        @foreach(Locales::get() as $locale)
            <li>
                <a href="{{ url('locale/'. $locale->code) }}">
                    {{ $locale->name }}
                </a>
            </li>
        @endforeach
    </ul>
</li>

API

Locales::get();
// array of supported locales

Locales::set('en');

Locales::current();
// the current locale instance

Locales::current()->code;
// or 
Locales::getCode();
// return : en

Locales::current()->name;
// or 
Locales::getName();
// return : English

Locales::current()->dir;
// or
Locales::getDir();
// return : ltr

Locales::current()->flag;
// or
Locales::getFlag();
// return : /images/flages/us.png

About

The package used to support multi locales in your application.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages