wanxsb/laravel-lang

List of 75 languages for Laravel 4, 5, 6 and 7
2,298 1
Install
composer require wanxsb/laravel-lang
Latest Version:v3.0.19
License:MIT
Last Updated:Apr 20, 2021
Links: GitHub  ·  Packagist
Maintainer: wanxsb

Features

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

Install

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

Laravel 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

PHP 扩展包开发

想知道如何从零开始构建 PHP 扩展包?

请关注我的实战课程,我会在此课程中分享一些扩展开发经验 —— 《PHP 扩展包实战教程 - 从入门到发布》

License

MIT

Related Packages

bartjansen1989/laravel-lang

List of 75 languages for Laravel 4, 5, 6 and 7

1,549 0
rkgrep/locales

Locale management package for Laravel.

497 0
overtrue/laravel-pinyin

Chinese to Pinyin translator.

621,991 530
arcanedev/laravel-lang

Translations manager and checker for Laravel 5 based on 'caouecs/laravel4-lang'...

71,636 70
ernysans/laraworld

Countries, Languages and Time Zones Package for Laravel 5.*

58,173 17