Skip to content
Publisher lang files for the Laravel Framework from caouecs/Laravel-lang
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Added sorting arrays when saving Apr 22, 2019
.codecov.yml First Initial Jan 26, 2018
.gitattributes First Initial Jan 26, 2018
.gitignore First Initial Jan 26, 2018
.styleci.yml Update .styleci.yml Jul 6, 2018
LICENSE Update LICENSE Jan 1, 2019
README.md Update README.md Apr 17, 2019
composer.json Added sorting arrays when saving Apr 22, 2019
composer.lock Added sorting arrays when saving Apr 22, 2019

README.md

Lang Publisher for caouecs/Laravel-lang package of Laravel 5.3+

Publisher lang files for the Laravel Framework from caouecs/Laravel-lang.

lang publisher

StyleCI Total Downloads Latest Stable Version Latest Unstable Version License

Contents

Installation

To get the latest version of Laravel Lang Publisher, simply require the project using Composer:

$ composer require andrey-helldar/laravel-lang-publisher --dev

Or manually update require-dev block of composer.json and run composer update.

{
    "require-dev": {
        "andrey-helldar/laravel-lang-publisher": "^2.0"
    }
}

For the 5.3-5.7 version of Laravel Framework, use version ^1.0:

{
    "require-dev": {
        "andrey-helldar/laravel-lang-publisher": "^1.0"
    }
}

If you don't use auto-discovery, add the ServiceProvider to the providers array in app/Providers/AppServiceProvider.php:

public function register()
{
    if($this->app->environment() !== 'production') {
        $this->app->register(\Helldar\LaravelLangPublisher\ServiceProvider::class);
    }
}

Compatibility table

Laravel version PHP version PHP tested version Recommended Package min version Package max version Comment
5.3 ^5.6.4 5.6.37 ^1.0 1.1.2 1.1.4 ---
5.4 ^5.6.4 5.6.37 ^1.0 1.0.0 1.1.4 ---
5.5 ^7.0.0 7.1.28 ^1.0 1.0.0 1.6.0 ---
5.6 ^7.1.3 7.2.13 ^1.0 1.0.0 1.6.0 ---
5.7 ^7.1.3 7.2.13 ^1.0 1.0.0 1.6.0 ---
5.8 ^7.1.3 7.3.3 ^2.0 1.0.0 >=2.0.0 You can install package ^1.0 version on the Laravel 5.8, but there are two nuances: translation files from version 5.7 will be copied, and there will be no support for saving validator keys.

How to use

Important

The package replaces only certain files in your lang directories:

auth.php
pagination.php
passwords.php
validation.php

If you made changes to the files, they will be saved.

He does not touch any other files.

Install language

When executing the php artisan lang:install command, the list of localizations. Example:

php artisan lang:install en de ro zh-CN lv
php artisan lang:install de

If files do not exist in the destination folder, they will be created. And if the files exist, the console will ask you for a replacement.

Also, if the files exist and you do not want to agree each time, you can pass the attribute --force or its alias -f for forced replacement.

php artisan lang:install de en ro zh-CN --force
php artisan lang:install de --force
php artisan lang:install de -f

Update language

When executing the php artisan lang:update command, the package learns which localizations are installed in your application and will replace the matching files.

Command php artisan lang:update is an alias of php artisan lang:install --force.

Features

Attention! This feature works only in Laravel 5.5 and higher with php 7.1.3 and higher.

When updating files, all comments from the final files are automatically deleted. Unfortunately, var_export does not know how to work with comments.

Your file example:

// auth.php
<?php

return [
    /*
    |--------------------------------------------------------------------------
    | Authentication Language Lines
    |--------------------------------------------------------------------------
    |
    | The following language lines are used during authentication for various
    | messages that we need to display to the user. You are free to modify
    | these language lines according to your application's requirements.
    |
    */
    'failed'   => 'These credentials do not match our records 123456.',
    'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
    'foo'      => 'bar',
];

Updated file:

// auth.php
<?php

return array (
    'failed' => 'These credentials do not match our records.',
    'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
    'foo' => 'bar',
);

And example of validation.php file: Your file:

<?php

return [
    /*
    |--------------------------------------------------------------------------
    | Validation Language Lines
    |--------------------------------------------------------------------------
    |
    | The following language lines contain the default error messages used by
    | the validator class. Some of these rules have multiple versions such
    | as the size rules. Feel free to tweak each of these messages here.
    |
    */
    'accepted'             => 'The :attribute must be accepted.',
    'active_url'           => 'The :attribute is not a valid URL.',
    
    // many rules
    
    'uuid'                 => 'The :attribute must be a valid UUID.',
    /*
    |--------------------------------------------------------------------------
    | Custom Validation Language Lines
    |--------------------------------------------------------------------------
    |
    | Here you may specify custom validation messages for attributes using the
    | convention "attribute.rule" to name the lines. This makes it quick to
    | specify a specific custom language line for a given attribute rule.
    |
    */
    'custom' => [
        'name' => [
            'required' => 'Custom message 1',
            'string'   => 'Custom message 2',
        ],
    ],
    /*
    |--------------------------------------------------------------------------
    | Custom Validation Attributes
    |--------------------------------------------------------------------------
    |
    | The following language lines are used to swap our attribute placeholder
    | with something more reader friendly such as "E-Mail Address" instead
    | of "email". This simply helps us make our message more expressive.
    |
    */
    'attributes' => [
        'name' => 'Foo',
        'bar'  => 'Bar',
        'baz'  => 'Baz',
    ],
];

Updated:

<?php

return array (
    'accepted' => 'The :attribute must be accepted.',
    'active_url' => 'The :attribute is not a valid URL.',
    
    // many rules
    
    'uuid' => 'The :attribute must be a valid UUID.',
    'custom' => array (
        'name' => array (
            'required' => 'Custom message 1',
            'string' => 'Custom message 2',
        ),
    ),
    'attributes' => array (
        'name' => 'Name',
        'username' => 'Nickname',
        'email' => 'E-Mail address',
        'first_name' => 'First Name',
        'last_name' => 'Last Name',
        'bar'  => 'Bar',
        'baz'  => 'Baz',
    ),
);

Copyright and License

Lang Publisher for caouecs/Laravel-lang package was written by Andrey Helldar for the Laravel framework 5.3 or above, and is released under the MIT License. See the LICENSE file for details.

You can’t perform that action at this time.