2017 © Pedro Peláez
 

library laravel-translation-manager

Manage Laravel Translations

image

addgod/laravel-translation-manager

Manage Laravel Translations

  • Wednesday, July 4, 2018
  • by Addgod
  • Repository
  • 1 Watchers
  • 0 Stars
  • 29 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 218 Forks
  • 0 Open issues
  • 28 Versions
  • 61 % Grown

The README.md

Laravel 5 Translation Manager

This is a translation manager, that can both replace the current translation manger, that comes with laravel, so that it runs of a datanbase, or it can be used to export translation files, so they can be checked into GIT., (*1)

As of now, there is no webinterface for this, but it is comming., (*2)

Installation

Require this package in your composer.json and run composer update (or run composer require addgod/laravel-translation-manager directly):, (*3)

"addgod/laravel-translation-manager": "^1"

After updating composer, add the ServiceProvider to the providers array in config/app.php, (*4)

'Addgod\TranslationManager\ManagerServiceProvider',

You need to run the migrations for this package., (*5)

$ php artisan vendor:publish --provider="Addgod\TranslationManager\ManagerServiceProvider" --tag=migrations
$ php artisan migrate

You need to publish the config file for this package. This will add the file config/translation-manager.php, where you can configure this package., (*6)

$ php artisan vendor:publish --provider="Addgod\TranslationManager\ManagerServiceProvider" --tag=config

Laravel >= 5.2

The configuration file by default only includes the auth middleware, but the latests changes in Laravel 5.2 makes it that session variables are only accessible when your route includes the web middleware. In order to make this package work on Laravel 5.2, you will have to change the route/middleware setting from the default, (*7)

    'route' => [
        'prefix' => 'translations',
        'middleware' => 'auth',
    ],

to, (*8)

    'route' => [
        'prefix' => 'translations',
        'middleware' => [
            'web',
            'auth',
        ],
    ],

NOTE: This is only needed in Laravel 5.2 (and up!), (*9)

Usage

Web interface

To use this translation manager, you need to make your own webinterface. Though a webinterface will come soon., (*10)

Import command

The import command will search through app/lang and load all strings in the database, so you can easily manage them., (*11)

$ php artisan translations:import

Translation strings from app/lang/locale.json files will be imported to the __json_ group., (*12)

Note: By default, only new strings are added. Translations already in the DB are kept the same. If you want to replace all values with the ones from the files, add the --replace (or -R) option: php artisan translations:import --replace, (*13)

Find translations in source

The Find command/button will look search for all php/twig files in the app directory, to see if they contain translation functions, and will try to extract the group/item names. The found keys will be added to the database, so they can be easily translated. This can be done through the webinterface, or via an Artisan command., (*14)

$ php artisan translations:find

If your project uses translation strings as keys, these will be stored into then __json_ group., (*15)

Export command

The export command will write the contents of the database back to app/lang php files. This will overwrite existing translations and remove all comments, so make sure to backup your data before using. Supply the group name to define which groups you want to publish., (*16)

$ php artisan translations:export <group>

For example, php artisan translations:export reminders when you have 2 locales (en/nl), will write to app/lang/en/reminders.php and app/lang/nl/reminders.php, (*17)

To export translation strings as keys to JSON files , use the --json (or -J) option: php artisan translations:import --json. This will import every entries from the __json_ group., (*18)

Clean command

The clean command will search for all translation that are NULL and delete them, so your interface is a bit cleaner. Note: empty translations are never exported., (*19)

$ php artisan translations:clean

Reset command

The reset command simply clears all translation in the database, so you can start fresh (by a new import). Make sure to export your work if needed before doing this., (*20)

$ php artisan translations:reset

Detect missing translations

Most translations can be found by using the Find command (see above), but in case you have dynamic keys (variables/automatic forms etc), it can be helpful to 'listen' to the missing translations. To detect missing translations, we can swap the Laravel TranslationServiceProvider with a custom provider. In your config/app.php, comment out the original TranslationServiceProvider and add the one from this package:, (*21)

//'Illuminate\Translation\TranslationServiceProvider',
'Addgod\TranslationManager\TranslationServiceProvider',

This will extend the Translator and will create a new database entry, whenever a key is not found, so you have to visit the pages that use them. This way it shows up in the webinterface and can be edited and later exported. You shouldn't use this in production, just in development to translate your views, then just switch back., (*22)

TODO

This package is still in development, but will go out of beta, when the webinterface is done., (*23)

- Add a webinterface
- Seed existing languages (https://github.com/caouecs/Laravel-lang)
- Suggestions are welcome :)

The Versions

04/07 2018

dev-master

9999999-dev

Manage Laravel Translations

  Sources   Download

MIT

The Requires

 

by Jesper Kold-Hansen

laravel translations translator

04/07 2018

v1.0.4

1.0.4.0

Manage Laravel Translations

  Sources   Download

MIT

The Requires

 

by Jesper Kold-Hansen

laravel translations translator

04/06 2018

v1.0.3

1.0.3.0

Manage Laravel Translations

  Sources   Download

MIT

The Requires

 

by Jesper Kold-Hansen

laravel translations translator

03/04 2018

v1.0.2

1.0.2.0

Manage Laravel Translations

  Sources   Download

MIT

The Requires

 

by Jesper Kold-Hansen

laravel translations translator

28/02 2018

v1.0.1

1.0.1.0

Manage Laravel Translations

  Sources   Download

MIT

The Requires

 

by Jesper Kold-Hansen

laravel translations translator

09/02 2018

dev-develop

dev-develop

Manage Laravel Translations

  Sources   Download

MIT

The Requires

 

by Jesper Kold-Hansen

laravel translations translator

09/02 2018

1.0.0

1.0.0.0

Manage Laravel Translations

  Sources   Download

MIT

The Requires

 

by Jesper Kold-Hansen

laravel translations translator

21/12 2017
02/09 2017
30/08 2017
21/06 2017

v0.3.0

0.3.0.0

Manage Laravel Translations

  Sources   Download

MIT

The Requires

 

laravel translations translator

14/06 2017

v0.2.9

0.2.9.0

Manage Laravel Translations

  Sources   Download

MIT

The Requires

 

laravel translations translator

12/05 2017

0.1.x-dev

0.1.9999999.9999999-dev

Manage Laravel Translations

  Sources   Download

MIT

The Requires

 

laravel translations translator

14/03 2017

v0.2.8

0.2.8.0

Manage Laravel Translations

  Sources   Download

MIT

The Requires

 

laravel translations translator

20/02 2017

dev-feat-search

dev-feat-search

Manage Laravel Translations

  Sources   Download

MIT

The Requires

 

laravel translations translator

25/01 2017

v0.2.7

0.2.7.0

Manage Laravel Translations

  Sources   Download

MIT

The Requires

 

laravel translations translator

24/01 2017

v0.2.6

0.2.6.0

Manage Laravel Translations

  Sources   Download

MIT

The Requires

 

laravel translations translator

28/09 2016

v0.2.5

0.2.5.0

Manage Laravel Translations

  Sources   Download

MIT

The Requires

 

laravel translations translator

31/08 2016

v0.2.4

0.2.4.0

Manage Laravel Translations

  Sources   Download

MIT

The Requires

 

laravel translations translator

17/08 2016

v0.2.3

0.2.3.0

Manage Laravel Translations

  Sources   Download

MIT

The Requires

 

laravel translations translator

27/05 2016

v0.2.2

0.2.2.0

Manage Laravel Translations

  Sources   Download

MIT

The Requires

 

laravel translations translator

16/06 2015

v0.2.1

0.2.1.0

Manage Laravel Translations

  Sources   Download

MIT

The Requires

 

laravel translations translator

16/06 2015

v0.1.4

0.1.4.0

Manage Laravel Translations

  Sources   Download

MIT

The Requires

 

laravel translations translator

16/06 2015

v0.2.0

0.2.0.0

Manage Laravel Translations

  Sources   Download

MIT

The Requires

 

laravel translations translator

02/06 2015

v0.1.3

0.1.3.0

Manage Laravel Translations

  Sources   Download

MIT

The Requires

 

laravel translations translator

17/09 2014

v0.1.2

0.1.2.0

Manage Laravel Translations

  Sources   Download

MIT

The Requires

 

laravel translations translator

01/06 2014

v0.1.1

0.1.1.0

Manage Laravel Translations

  Sources   Download

MIT

The Requires

 

laravel translations translator

01/06 2014

v0.1.0

0.1.0.0

Manage Laravel Translations

  Sources   Download

MIT

The Requires

 

laravel translations translator