🌏 52 languages support for Laravel 5 application.
PHP
Clone or download
Permalink
Failed to load latest commit information.
src Apply fixes from StyleCI (#29) May 1, 2018
.gitignore Add .gitignore. Oct 28, 2017
.php_cs Fixed #24 Oct 28, 2017
LICENSE init commit Mar 13, 2015
README.md Update README.md May 1, 2018
README_CN.md Update README. Nov 25, 2016
composer.json Auto discovery. Jul 2, 2017

README.md

Laravel-lang

52 languages support for Laravel 5 application based on caouecs/Laravel-lang. 中文说明

For Laravel 5 For Lumen 5 Latest Stable Version Latest Unstable Version Total Downloads License

Features

  • Laravel 5 & Lumen support.
  • Translations Publisher.
  • Made with 💖.

Install

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

Laraval 5.*

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

Illuminate\Translation\TranslationServiceProvider::class,

with:

Overtrue\LaravelLang\TranslationServiceProvider::class,

Lumen

Add the following line to bootstrap/app.php:

$app->register(Overtrue\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