44 languages for Laravel 5 based on Laravel4-lang.
composer require "overtrue/laravel-lang:dev-master"
or add the following line to your project's composer.json
:
"require": {
"overtrue/laravel-lang": "dev-master"
}
then
composer update
After completion of the above, Replace the config/app.php
content
'Illuminate\Translation\TranslationServiceProvider'
into
'Overtrue\LaravelLang\TranslationServiceProvider',
Modify the project language:
config/app.php
:
'locale' => 'zh-CN',
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.
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 已经注册过!
We assume that want to replace the password.reset
message:
resources/lang/zh-CN/passwords.php
:
<?php
return [
'reset' => '您的密码已经重置成功了,你可以使用新的密码登录了!',
];
You need only add the part what you want.
MIT