Skip to content

novalevel/laravel-lang

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel-lang

52 languages support for Laravel 5 application based on caouecs/Laravel-lang.

中文说明

Latest Stable Version Total Downloads Latest Unstable Version License

Install

$ composer require "overtrue/laravel-lang:~2.0"

After completion of the above, Replace the config/app.php content

Illuminate\Translation\TranslationServiceProvider::class,

with:

Overtrue\LaravelLang\TranslationServiceProvider::class,

Configuration

you can change the locale at config/app.php:

'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' => '[email protected]']);
// 邮箱 [email protected] 已经注册过!

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 vendor:publish --provider="Overtrue\LaravelLang\TranslationServiceProvider" --tag=resouece

or force publish(will overwrite old files):

$ php artisan vendor:publish --provider="Overtrue\LaravelLang\TranslationServiceProvider" --tag=resource --force

License

MIT

About

52 languages support for Laravel 5 application.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%