arispati / app-locale by arispati

Localization for Laravel and Lumen Framework
19,782
1
2
Package Data
Maintainer Username: arispati
Maintainer Contact: masarispati@gmail.com (Aris)
Package Create Date: 2021-08-06
Package Last Update: 2021-08-06
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-11-24 15:07:13
Package Statistics
Total Downloads: 19,782
Monthly Downloads: 757
Daily Downloads: 4
Total Stars: 1
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

App Locale

Localization for Laravel and Lumen Framework

Description

This package will set the locale of the application by the request that contains the App-Locale attribute in the header

How to Install

  • Install with composer
composer require arispati/app-locale

Laravel

  • Register the middleware
// app/Http/Kernel.php
protected $middleware = [
    // ...
    \Arispati\AppLocale\Middleware\AppLocale::class
];

Lumen

  • Register the middleware
// bootstrap/app.php
$app->middleware([
    \Arispati\AppLocale\Middleware\AppLocale::class
]);
  • if you want to use Facade
// bootstrap/app.php

// Enabled Facade
$app->withFacades(true, [
    '\Arispati\AppLocale\Facades\AppLocale' => 'AppLocale'
]);

// Register service provider
$app->register(\Arispati\AppLocale\ServiceProvider::class);

Available Method

  • Set app locale
AppLocale::setLocale('id'); // set app locale to 'id' (Bahasa Indonesia)
  • Get app locale
AppLocale::getLocale();