xianbaihong / laravel-lang
List of 75 languages for Laravel.
Fund package maintenance!
overtrue
Requires
- ext-json: *
- laravel-lang/lang: ^15.0
- symfony/process: ^6.0
Requires (Dev)
- laravel/framework: ^9.0
This package is auto-updated.
Last update: 2025-03-13 15:51:50 UTC
README
基于 Laravel-Lang/lang 的Laravel应用程序支持75种语言。
Install
Laravel version | Composer command |
---|---|
Laravel 9.x | composer require xianbaihong/laravel-lang:~6.0 |
Laravel 7.x-8.x | composer require xianbaihong/laravel-lang:~5.0 |
Laravel 6.x | composer require xianbaihong/laravel-lang:~4.0 |
Laravel 5.8 | composer require xianbaihong/laravel-lang:~3.0 |
Laravel 5.1-5.7 | composer require xianbaihong/laravel-lang:~2.0 |
Laravel 5 | composer require xianbaihong/laravel-lang:~1.0 |
composer require "xianbaihong/laravel-lang:~6.0"
Lumen
Add the following line to bootstrap/app.php
:
$app->register(Xianbaihong\LaravelLang\TranslationServiceProvider::class);
Configuration
Laravel
you can change the locale at config/app.php
:
'locale' => 'zh_CN',
Lumen
set locale in .env
file:
APP_LOCALE=zh_CN
Usage
There is no difference with the usual usage.
If you need to add additional language content, Please create a file in the resources/lang/{LANGUAGE}
directory.
Add custom language items
Here, for example in Chinese:
resources/lang/zh_CN/demo.php
:
<?php return [ 'user_not_exists' => '用户不存在', 'email_has_registed' => '邮箱 :email 已经注册过!', ];
Used in the template:
echo trans('demo.user_not_exists'); // 用户不存在 echo trans('demo.email_has_registed', ['email' => 'anzhengchao@gmail.com']); // 邮箱 anzhengchao@gmail.com 已经注册过!
Replace the default language items partially
We assume that want to replace the password.reset
message:
resources/lang/zh_CN/passwords.php
:
<?php return [ 'reset' => '您的密码已经重置成功了,你可以使用新的密码登录了!', ];
You need only add the partials item what you want.
publish the language files to your project resources/lang/
directory
php artisan lang:publish [LOCALES] {--force}
examples:
php artisan lang:publish zh_CN,zh_HK,th,tk
License
MIT