75 languages support for Laravel 5 application based on Laravel-Lang/lang.

Overview

Laravel-lang

75 languages support for Laravel 5 application based on Laravel-Lang/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 💖 .

Sponsor me

Install

Laravel version Composer command
Laravel 7.x-8.x composer require overtrue/laravel-lang:~5.0
Laravel 6.x composer require overtrue/laravel-lang:~4.0
Laravel 5.8 composer require overtrue/laravel-lang:~3.0
Laravel 5.1-5.7 composer require overtrue/laravel-lang:~2.0
Laravel 5 composer require overtrue/laravel-lang:~1.0
$ composer require "overtrue/laravel-lang:~5.0"

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:



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:



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

❤️ Sponsor me

Sponsor me

如果你喜欢我的项目并想支持它,点击这里 ❤️

Project supported by JetBrains

Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.

PHP 扩展包开发

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

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

License

MIT

Issues
  • MAC使用php artisan lang:publish zh-CN 报错

    MAC使用php artisan lang:publish zh-CN 报错

    chenjinhaodeMacBook-Pro:rarone_watch chenjinhao$ php artisan lang:publish zh-CN

    cp: /Applications/MAMP/htdocs/rarone_watch/vendor/caouecs/laravel-lang/src/zh-CN /Applications/MAMP/htdocs/rarone_watch/vendor/caouecs/laravel-lang/json/zh-CN.json: No such file or directory

    published languages (no overwrite): ["zh-CN"].

    opened by richarduncle 15
  • 发布的时候报错

    发布的时候报错

    根据文档上的示例, 在执行

    $ php artisan lang:publish zh_CN
    

    命令的时候报错, 同时配置文件里边也不正确;

    还是得使用zh-CN

    opened by nilsir 7
  • laravel5.4之前安装有用,现在没用了

    laravel5.4之前安装有用,现在没用了

    laravel5.4之前安装有用,今天尝试了两次 都没有效果

    opened by maokeyang 6
  • Call to undefined function Overtrue\LaravelLang\resource_path()

    Call to undefined function Overtrue\LaravelLang\resource_path()

    After last update when I do a php artisan clear-compiled I recive the following error:

    [Symfony\Component\Debug\Exception\FatalErrorException]
    Call to undefined function Overtrue\LaravelLang\resource_path()

    Script php artisan clear-compiled handling the post-update-cmd event returned with an error

    opened by grudge61 6
  • Use de for de-CH, de-AT and so on

    Use de for de-CH, de-AT and so on

    I want to use the German locale pack also for locales of austria and switzerland. How to do so? Do I have to copy the files?

    opened by amenk 6
  • Old version of translation

    Old version of translation

    When I try to publish the translation file, I note that was an old version of Caouse-laravel-lang files.

    I hope to check it to publish the newest translation files.

    opened by mohamedsabil83 5
  • WINDOWS  laravel  php artisan lang:publish zh-CN,zh-HK,zh-TW  报错

    WINDOWS laravel php artisan lang:publish zh-CN,zh-HK,zh-TW 报错

    'cp' is not recognized as an internal or external command, operable program or batch file.

    如何解决

    opened by licecn 5
  • 为什么我的会报错啊

    为什么我的会报错啊

    我已经在homesteaad里面执行了composer命令,但是phpstorm项目里面还是出错了啊: image image

    opened by zhangwei900808 5
  • Update laravel-lang/lang requirement from ^8.0 to ^10.1

    Update laravel-lang/lang requirement from ^8.0 to ^10.1

    Updates the requirements on laravel-lang/lang to permit the latest version.

    Changelog

    Sourced from laravel-lang/lang's changelog.

    [10.1.0] - 2021-06-02

    Changed

    • feature: [ms] #1772 auth.php

    Reference

    • add Laravel Breeze

    Todo script

    • fix: #1762 Some translations have been lost in the new version (10.0)

    [10.0.2] - 2021-05-30

    Changed

    • feature: [de] #1759 cashier jetstream nova spark-paddle spark-stripe
    • feature: [es] #1760 nova
    • feature: [pt_BR] #1767 #1769 #1771 exclude cashier jetstream nova spark-paddle spark-stripe validation-inline
    • feature: [tr] #1766 #1768 #1770 exclude auth jetstream nova spark-paddle spark-stripe json file

    [10.0.1] - 2021-05-24

    Changed

    • feature: [ar] #1757 jetstream spark-paddle spark-stripe
    • feature: [es] #1753 jetstream spark-paddle spark-stripe
    • feature: [fi] #1758 exclude auth.php cashier fortify jetstream nova spark-paddle spark-stripe validation-inline.php validation.php json file
    • feature: [fr] cashier jetstream nova spark-paddle spark-stripe
    • feature: [ru] #1751 cashier jetstream spark-paddle spark-stripe
    • feature: [vi] #1756 cashier jetstream spark-paddle
    • feature: [zh_TW] #1754 validation-inline.php json file

    Todo script

    • fix: #1751
    • feature: #1752 Added dock block to structure splitter file

    [10.0.0] - 2021-05-20

    Changed

    • feature: [de] #1750 json file
    • feature: [nb] #1747 auth.php pagination.php passwords.php validation-inline.php validation.php json file

    Reference

    • feature: #1748 Split translation keys into Laravel packages

    ... (truncated)

    Commits
    • 60f3438 doc for 10.1.0
    • 4ccc94e Updated status of translations
    • cd8a396 Updating the file
    • ae8b99f Merge pull request #1762 from andrey-helldar/patch/2021-05-26/22-46
    • ab54cb8 Resolving merge conflict
    • 6f8b39c Merge remote-tracking branch 'caouecs/master' into patch/2021-05-26/22-46
    • 5c2532b Update tests
    • 9640443 Update script app/status.php
    • 25cdb9b Update script app/keys.php
    • 1b40b00 Updated status of translations
    • Additional commits viewable in compare view

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 4
  • Laravel 5.4 trans()不能正常使用

    Laravel 5.4 trans()不能正常使用

    5.4 Translator.php trans方法移除了$domain = 'messages'传参

        public function trans($key, array $replace = [], $locale = null)
        {
            return $this->get($key, $replace, $locale);
        }
    
    opened by mugennsou 4
  • "cp"不被识别为内部或外部命令、可操作程序或批处理文件,自己的解决方式,不喜勿喷

    vendor\overtrue\laravel-lang\src\Commands\Publish.php下的handle方法 删除或注释掉文件数组添加.json文件的相关代码 ` /** * Execute the console command. * * @return mixed */ public function handle() { $locale = \str_replace('-', '_', $this->argument('locales')); $force = $this->option('force') ? 'f' : 'n';

        $sourcePath = base_path('vendor/laravel-lang/lang/locales');
        $sourceJsonPath = base_path('vendor/laravel-lang/lang/locales');
        $targetPath = base_path('resources/lang/');
    
        if (!is_dir($targetPath) && !mkdir($targetPath)) {
            return $this->error('The lang path "resources/lang/" does not exist or not writable.');
        }
    
        $files = [];
        $published = [];
        $copyEnFiles = false;
        $inLumen = $this->laravel instanceof \Laravel\Lumen\Application;
    
        if ('all' == $locale) {
            $files = [
                \addslashes($sourcePath) . '/*',
                \addslashes($sourceJsonPath) . '/*/*.json',
            ];
            $message = 'all';
            $copyEnFiles = true;
        } else {
            foreach (explode(',', $locale) as $filename) {
                if ('en' === $locale) {
                    $copyEnFiles = true;
    
                    continue;
                }
    
                $trimFilename = trim($filename);
                $file = $sourcePath . '/' . $trimFilename;
    
                if (!file_exists($file)) {
                    $this->error("'$filename' not found.");
    
                    continue;
                }
    
                $published[] = $filename;
                $files[] = escapeshellarg($file);
    
                /*$jsonFile = $sourceJsonPath . "/{$trimFilename}/{$trimFilename}" . '.json';
                if (!file_exists($jsonFile)) {
                    $this->error("'$filename' not found.");
    
                    continue;
                }
                $files[] = escapeshellarg($jsonFile);*/
            }
    
            if (empty($files)) {
                return;
            }
    
            $message = json_encode($published);
        }
    
        if ($inLumen && $copyEnFiles) {
            $files[] = escapeshellarg(base_path('vendor/laravel/lumen-framework/resources/lang/en'));
        }
    
        array_map(function ($file) use ($targetPath) {
            $file = str_replace("\\", "/", $file);
            $targetPath = str_replace("\\", "/", $targetPath);
            $result = $this->cp($file, $targetPath);
            $this->info("copy {$file} to $targetPath result: " . json_encode($result));
        }, $files);
        /*$files = implode(' ', $files);
        $targetPath = escapeshellarg($targetPath);
        $command = "cp -r{$force} {$files} {$targetPath}";
        $process = \method_exists(Process::class, 'fromShellCommandline') ? Process::fromShellCommandline($command) : new Process($command);
    
        $process->run(function ($type, $buffer) {
            if (Process::ERR === $type) {
                return $this->error(trim($buffer));
            }
        });
    
        $type = ('f' == $force) ? 'overwrite' : 'no overwrite';
    
        $this->info("published languages <comment>({$type})</comment>: {$message}.");*/
    }
    
    /**
     *$param 来源文件夹或者文件$src
     *$param 目的地 $des
     *返回值,true或者false
     */
    function cp($src, $des)
    {
        // 删除路径左右两侧的双引号
        $src = rtrim(ltrim($src, "\""), "\"");
        // 清除文件状态缓存
        clearstatcache($src);
        //假如是文件并且目的地不存在则创建目的地,并把文件放在目的地之下
        if (is_file($src)) {
            var_dump($des . '/' . dirname($src));
            //目的地不存在则创建目的地
            if (!file_exists($des) && !is_dir($des)) {
                mkdir($des, 0777, true);
            }
            copy($src, $des . '/' . basename($src));
            //假如是目录
        } else if (is_dir($src)) {
            //目的地不存在则创建目的地
            if (!file_exists($des) && !is_dir($des)) {
                mkdir($des, 0777, true);
            }
            //遍历目录下面的文件
            foreach (glob($src . '/*') as $f) {
                //假如目录下面的文件是目录则对它进行递归复制
                if (is_dir($f)) {
                    $this->cp($f, $des . '/' . basename($f));
                } else {
                    $baseDir = $des . '/' . basename($src);
                    if (!file_exists($baseDir) && !is_dir($baseDir)) {
                        mkdir($baseDir, 0777, true);
                    }
                    $to = $baseDir . '/' . basename($f);
                    if (!file_exists($to)) {
                        fopen($to, "w+");
                    }
                    //文件则复制到目的地
                    copy($f, $to);
                }
            }
        } else {
            return false;
        }
        return true;
    }`
    
    opened by jingzhizz 0
  • 字段 验证提示 还是英文

    字段 验证提示 还是英文

    Laravel Framework 8.68.0

    "overtrue/laravel-lang": "^5.0",

    app.php 设置 'locale' => 'zh_CN', 验证 提示 是 phone 必须介于 3 - 10 个字符之间。 , 这个 phone 字段 在 validation-attributes.php 文件中 有定义, 没有 将 phone 提示为手机

    猜测: validation-attributes.phpvalidation-inline.php 都没有起作用

    validation.php 文件中 添加

    'attributes' => [
        'phone'         => '手机号',
    ],
    

    这样 才有作用

    bug todo :spiral_notepad: 
    opened by gyp719 4
  • cp win 下不支持,照顾下win

    cp win 下不支持,照顾下win

    'cp' is not recognized as an internal or external command,

    opened by lwk5213 0
Releases(5.0.2)
Owner
安正超
Keep calm and coding.
安正超
List of 77 languages for Laravel Framework 4, 5, 6, 7 and 8, Laravel Jetstream , Laravel Fortify, Laravel Cashier and Laravel Nova.

Laravel Lang In this repository, you can find the lang files for the Laravel Framework 4/5/6/7/8, Laravel Jetstream , Laravel Fortify, Laravel Cashier

Laravel Lang 6.3k Jan 15, 2022
Extracts translatable strings from source. Identical to xgettext but for template languages.

xgettext-template Extracts translatable strings from source. Identical to xgettext(1) but for template languages. Template language support Handlebars

Guillaume C. Marty 78 Aug 30, 2021
Easy multilingual urls and redirection support for the Laravel framework

Linguist - Multilingual urls and redirects for Laravel This package provides an easy multilingual urls and redirection support for the Laravel framewo

Tanel Tammik 188 Dec 26, 2021
Support multiple language resources for Laravel

Laratrans Support multiple language resources for Laravel. Docs Installation composer require lechihuy/laratrans After you install the package success

Lê Chí Huy 3 Dec 21, 2021
Trait for multilingual resource file support

⚡ Usage This library supports MultilingualResourceTrait which can be used in PluginBase. Multilingual support of resource files is possible using this

PocketMine-MP projects of PresentKim 1 Oct 23, 2021
Provides support for message translation and localization for dates and numbers.

The I18n library provides a I18n service locator that can be used for setting the current locale, building translation bundles and translating messages. Additionally, it provides the Time and Number classes which can be used to output dates, currencies and any numbers in the right format for the specified locale.

CakePHP 24 Oct 2, 2021
The Translation component provides tools to internationalize your application.

Translation Component The Translation component provides tools to internationalize your application. Getting Started $ composer require symfony/transl

Symfony 6.2k Jan 13, 2022
Easy localization for Laravel

Laravel Localization Easy i18n localization for Laravel, an useful tool to combine with Laravel localization classes. The package offers the following

Marc Cámara 2.8k Jan 12, 2022
[Deprecated] A Laravel package for multilingual models

This package has been deprecated. But worry not. You can use Astrotomic/laravel-translatable. Laravel-Translatable If you want to store translations o

Dimitris Savvopoulos 2k Jan 17, 2022
Better translation management for Laravel

Better localization management for Laravel Introduction Keeping a project's translations properly updated is cumbersome. Usually translators do not ha

Waavi 344 Dec 14, 2021
Package to manage Laravel translations locally

Translation Manager For Laravel Easy to use package that helps you with the translation of your Laravel application locally. Features ✅ Check all loca

null 5 Jan 8, 2022
Laravel translation made __('simple').

Translation.io client for Laravel 5.5+/6/7/8 Add this package to localize your Laravel application. Use the official Laravel syntax (with PHP or JSON

Translation.io 67 Jan 8, 2022
🎌 Laravel Localization Helper :: Easily add translation variables from Blade templates.

LocalizationHelper Package for convenient work with Laravel's localization features and fast language files generation. Take a look at contributing.md

Awes.io 37 Jan 15, 2022
Manage Laravel translation files

Laravel 5 Translation Manager For Laravel 4, please use the 0.1 branch! This is a package to manage Laravel translation files. It does not replace the

Barry vd. Heuvel 1.4k Jan 9, 2022
A Gui To Manage Laravel Translation Files

Lingo A file based translation manager, which unlike other Lang managers don't need a database connection to handle the translation. Installation comp

Muah 93 Dec 21, 2021
A GUI for managing JSON translation files in your laravel projects.

Laravel Language Manager Langman is a GUI for managing your JSON language files in a Laravel project. Installation Begin by installing the package thr

Mohamed Said 515 Dec 19, 2021
🗓 A library to help you work with dates in multiple languages, based on Carbon.

Date This date library extends Carbon with multi-language support. Methods such as format, diffForHumans, parse, createFromFormat and the new timespan

Jens Segers 1.8k Jan 5, 2022
This project is very diverse and based upon many languages and libraries such as C++, Python, JavaScript, PHP and MQTT

ADMS-Real-time-project This project is very diverse and based upon many languages and libraries such as C++, Python, JavaScript, PHP and MQTT Advance_

Nitya parikh 1 Dec 1, 2021
List of 77 languages for Laravel Framework 4, 5, 6, 7 and 8, Laravel Jetstream , Laravel Fortify, Laravel Breeze, Laravel Cashier, Laravel Nova and Laravel Spark.

Laravel Lang In this repository, you can find the lang files for the Laravel Framework 4/5/6/7/8, Laravel Jetstream , Laravel Fortify, Laravel Cashier

Laravel Lang 6.3k Jan 16, 2022
List of 77 languages for Laravel Framework 4, 5, 6, 7 and 8, Laravel Jetstream , Laravel Fortify, Laravel Cashier and Laravel Nova.

Laravel Lang In this repository, you can find the lang files for the Laravel Framework 4/5/6/7/8, Laravel Jetstream , Laravel Fortify, Laravel Cashier

Laravel Lang 6.3k Jan 15, 2022
Links statistics & link tracking for laravel 5, It tracks down browsers, operating systems, languages and more

Links Links statistics for laravel 5 Table Of Contents Installation Configuration Usage Installation To install charts use composer Download composer

Erik C. Forés 52 Jul 31, 2021
Laravel 5 Package to Detect Users Browsers, Devices, Languages and Operating Systems

laravel-identify Laravel 5 Package to identify a User's Browser, Operating System, Language and Device Installation PHP 7.1+ or HHVM 3.3+, and Compose

Prosper Otemuyiwa 183 Jan 13, 2022
:globe_with_meridians: List of all countries with names and ISO 3166-1 codes in all languages and data formats.

symfony upgrade fixer • twig gettext extractor • wisdom • centipede • permissions handler • extraload • gravatar • locurro • country list • transliter

Saša Stamenković 4.8k Jan 19, 2022
highlight.php is a server-side syntax highlighter written in PHP that currently supports 185 languages

highlight.php is a server-side syntax highlighter written in PHP that currently supports 185 languages. It's a port of highlight.js by Ivan Sagalaev that makes full use of the language and style definitions of the original JavaScript project.

Geert Bergman 601 Jan 16, 2022
Get estimated read time of an article. Similar to medium.com's "x min read". Multilingual including right-to-left written languages. Supports JSON, Array and String output.

Read Time Calculates the read time of an article. Output string e.g: x min read or 5 minutes read. Features Multilingual translations support. Static

Waqar Ahmed 6 Sep 7, 2021
Judge0 API integration for running/judging code with different languages

Laravel Judge0 Judge0 API integration for running/judging code with different languages use Mouadbnl\Judge0\Models\Submission; $submission = Submissi

Mouad Benali 7 Dec 21, 2021
List of 77 languages for HTTP statuses

Laravel Lang: HTTP Statuses List of 77 languages for HTTP statuses Installation To get the latest version of Laravel Lang: HTTP Statuses library, simp

Laravel Lang 5 Jan 2, 2022
Commenting program developed with Html & Css & Php JavaScript Languages ​​and MySql

CommentSystem [BETA] Commenting program developed with Html & Css & Php JavaScript Languages and MySql How does it work ? After you set up your Databa

Azad 1 Jan 1, 2022
Learning design patterns by implementing them in various programming languages.

design-patterns Learning design patterns by implementing them in various programming languages. Creational design patterns Creational design patterns

Paweł Tryfon 1 Dec 13, 2021