All Projects → akaunting → Laravel Language

akaunting / Laravel Language

Licence: mit
Language switcher package for Laravel

Programming Languages

language
365 projects

Labels

Projects that are alternatives of or similar to Laravel Language

Tags
A Tagging package that easily allows you to add tags to your Eloquent models.
Stars: ✭ 134 (-2.19%)
Mutual labels:  laravel
Twitter
Twitter Notifications Channel for Laravel
Stars: ✭ 135 (-1.46%)
Mutual labels:  laravel
Blade Extensions
Laravel Blade Extension Classes for Laravel 5
Stars: ✭ 136 (-0.73%)
Mutual labels:  laravel
Laravel Responsecache
Speed up a Laravel app by caching the entire response
Stars: ✭ 1,874 (+1267.88%)
Mutual labels:  laravel
Paste.laravel.io
The Laravel.io Pastebin.
Stars: ✭ 135 (-1.46%)
Mutual labels:  laravel
Laravel Vite
Vite integration for Laravel
Stars: ✭ 134 (-2.19%)
Mutual labels:  laravel
Laravel Queue Kafka
Kafka Queue driver for Laravel
Stars: ✭ 134 (-2.19%)
Mutual labels:  laravel
Laravel Tutorial
Laravel 中文新手书籍《Laravel 入门教程》的源代码
Stars: ✭ 136 (-0.73%)
Mutual labels:  laravel
Forum
A fully-fledged modern forum app, including @mention and private messaging, built with Laravel 5.3 and Vue 2.
Stars: ✭ 135 (-1.46%)
Mutual labels:  laravel
Laravel Queue Monitor
Monitoring Laravel Jobs with your Database
Stars: ✭ 136 (-0.73%)
Mutual labels:  laravel
Laratrust
Handle roles and permissions in your Laravel application
Stars: ✭ 1,799 (+1213.14%)
Mutual labels:  laravel
Laravel Artisan Dd
Quickly run some code via Artisan
Stars: ✭ 136 (-0.73%)
Mutual labels:  laravel
Azuriom
Azuriom is a modern, reliable, fast and secure game CMS.
Stars: ✭ 135 (-1.46%)
Mutual labels:  laravel
Webstack Laravel
一个开源的网址导航网站项目,您可以拿来制作自己的网址导航。
Stars: ✭ 1,908 (+1292.7%)
Mutual labels:  laravel
Laravel Hashslug
Package providing a trait to use Hashids on a model
Stars: ✭ 136 (-0.73%)
Mutual labels:  laravel
Laravel Tinker Tools
Use short class names in an Artisan tinker session
Stars: ✭ 134 (-2.19%)
Mutual labels:  laravel
Concord
Laravel extension for building modular applications where modules are decoupled, re-usable and easily customizable
Stars: ✭ 135 (-1.46%)
Mutual labels:  laravel
Laravel Deletable
👾 Gracefully restrict deletion of Laravel Eloquent models
Stars: ✭ 137 (+0%)
Mutual labels:  laravel
Laravel Ssh Tunnel
Easy creation & maintenance of an SSH Tunnel for Laravel/Lumen
Stars: ✭ 134 (-2.19%)
Mutual labels:  laravel
Laravel Authz
An authorization library that supports access control models like ACL, RBAC, ABAC in Laravel.
Stars: ✭ 136 (-0.73%)
Mutual labels:  laravel

Language switcher package for Laravel

Downloads StyleCI Quality License

This package allows switching locale easily on Laravel projects. It's so simple to use, once it's installed, your App locale will change only by passing routes into SetLanguage middleware.

Top features:

  • Change automatically app locale depending on user browser configuration
  • Language flags built-in for easy implementation
  • Get language name like 'English' or 'Español' from codes such as 'en' or 'es'
  • Option to choose short (en) or long (en-GB) language code
  • Store locale on users table
  • Restrict users to set languages you don't have translations
  • Helper functions for clean, simple and easy to read API
  • Supports Carbon and Date packages

Getting Started

1. Install

Run the following command:

composer require akaunting/laravel-language

2. Register (for Laravel < 5.5)

Register the service provider in config/app.php

Akaunting\Language\Provider::class,

Add alias if you want to use the facade.

'Language'   => Akaunting\Language\Facade::class,

3. Publish

Publish config, migration and blade files.

php artisan vendor:publish --tag=language

4. Migrate

Add locale column to users table:

php artisan migrate

5. Configure

Default values can be modified also on config/language.php

Keys

  • route: Makes route available
  • carbon: Sets briannesbitt/carbon translator language
  • date: Sets jenssegers/date translator language
  • home: Make home route available
  • auto: Sets language automatically depending on user's browser config
  • prefix: Prefix of routes URI to set locale
  • middleware: default middleware to set locale
  • controller: default controller to handle locale
  • flags: Settings such as width, class etc for flags
  • mode: The language code and name mode
  • allowed: Allowed language codes
  • all: Available language names and codes

Usage

Middleware

All routes in which you want to set language should be under the language middleware to set at each request to App locale.

Route::group(['middleware' => 'language'], function () {

    // Here your routes

});

URL

  • Via URL with return home: /languages/{locale}/home
  • Via URL with return back: /languages/{locale}/back

Tip: /languages prefix can be changed from config/language.php

Methods

language()->allowed()

Returns an array with [$code => $name] for all allowed languages of config. Example usage on blade:

@foreach (language()->allowed() as $code => $name)
    <a href="{{ language()->back($code) }}">{{ $name }}</a>
@endforeach

language()->flags()

Returns an output with flags for all allowed languages of config. Output can be changed from resources/views/vendor/language folder

language()->flag()

Returns the flag of the current locale. Output can be changed from resources/views/vendor/language folder

language()->names($codes = null)

Get an array like [$code => $name] from an array of only $codes.

language()->codes($langs = null)

Get an array like [$name => $code] from an array of only $langs.

language()->back($code)

Returns the URL to set up language and return back: back()

Also if you prefer to use directly route() function you can use it as following code:

{{ route('language::back', ['locale' => $code]) }}

language()->home($code)

Returns the URL to set language and return to home: url('/')

Also if you prefer to use directly route() function you can use it as following code:

{{ route('language::home', ['locale' => $code]) }}

language()->getName($code = 'default')

Returns the language name of $code if specified or the current language set if not.

Tip: Use app()->getLocale() to get the current locale

language()->getCode($name = 'default')

Returns the language code of $name if specified or the current language set if not.

Changelog

Please see Releases for more information what has changed recently.

Contributing

Pull requests are more than welcome. You must follow the PSR coding standards.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see LICENSE for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].