Skip to content

🎌 Laravel Localization Helper :: Easily add translation variables from Blade templates.

License

GPL-3.0, Unknown licenses found

Licenses found

GPL-3.0
LICENSE
Unknown
license.md
Notifications You must be signed in to change notification settings

awes-io/localization-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LocalizationHelper

Coverage report Build status Composer Ready Downloads Last version

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

Installation

Via Composer

$ composer require awes-io/localization-helper

In Laravel 5.5+, service provider and facade will be automatically registered. For older versions, follow the steps below:

Register service provider in config/app.php:

'providers' => [
// [...]
        AwesIO\LocalizationHelper\LocalizationHelperServiceProvider::class,
],

You may also register LaravelLocalization facade:

'aliases' => [
// [...]
        'LocalizationHelper' => AwesIO\LocalizationHelper\Facades\LocalizationHelper::class,
],

Config

Config Files

In order to edit default configuration you may execute:

php artisan vendor:publish --provider="AwesIO\LocalizationHelper\LocalizationHelperServiceProvider"

After that, config/localizationhelper.php will be created.

Usage

Package registers global helper function _p($file_key, $default, $placeholders):

_p('auth.login', 'Login'); // "Login"

It will create new localization file auth.php (if it doesn't exist) and write second parameter as language string under login key:

return [
    "login" => "Login"
];

On second call with same file/key _p('auth.login'), localization string will be returned, file will remain untouched.

Placeholders are also supported:

_p(
    'mail.invitation', 
    'You’re invited to join :company company workspace', 
    ['company' => 'Awesio']
);

If key is returned, it means that string already exists in localization file and you are trying to add new one using its value as an array.

// in localization file.php
return [
    "test" => "Test string"
];

_p('file.test.new', 'Test string'); // will return "file.test.new"

_p('file.test_2.new', 'Test string'); // will return "Test string"

// and modify localization file:
return [
    "test" => "Test string",
    "test_2" => [
        "new" => "Test string"
    ]
];

Change log

Please see the changelog for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email info@awescrm.de instead of using the issue tracker.

Credits

License

MIT

About

🎌 Laravel Localization Helper :: Easily add translation variables from Blade templates.

Topics

Resources

License

GPL-3.0, Unknown licenses found

Licenses found

GPL-3.0
LICENSE
Unknown
license.md

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages