2017 © Pedro Peláez
 

library laravel-translation-manager

Lets you manage your Laravel-translation files via database.

image

brotzka/laravel-translation-manager

Lets you manage your Laravel-translation files via database.

  • Tuesday, February 13, 2018
  • by Brotzka
  • Repository
  • 1 Watchers
  • 2 Stars
  • 22 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 69 % Grown

The README.md

Codacy Badge Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

Laravel Translation Manager

This package provides an easy way to manage your translations in a database. It takes all files from your default locale folder (e.g. resources/lang/de) and creates translation-groups (e.g. auth.php becomes translation-group auth) which are stored in translation_groups-table. Then every entry from each file will be saved to the translations-table (yes, it takes care of multidimensional arrays of every depth)., (*2)

After you have finished translating, the package writes all entries back to the resource-folder. All entries will be kept in database, so you can keep translating., (*3)

Updates are handled one-way. That means that changes which are made to a file will not replace the value in the database. The other way round, the complete content of a translation-file will be replaced by the values from the database., (*4)

Pros:

  • Laravels default translation-loader will not be replaced, so everything keeps working
  • Works with every Laravel version (5.*)
  • To add a new language, simply add it to your config/app.php and re-run php artisan translations:toDatabse, make your translations and run php artisan translations:toFile
  • No more database exports! Develop locally without using the export function. Simply use your default language.

Installation

  • require via composer composer require brotzka/translation-manager
  • add list of available languages to your config/app.php: 'available_locales' => ['de', 'en', 'sv'],
  • run migration php artisan migrate

Commands

translations:toDatabase

Call via:, (*5)

php artisan translations:toDatabase

Collects all files and entries from within your resources/lang/ folder and generates translations-groups and translations and writes them to the database. Existing files will NOT be updated., (*6)

translations:toFile

Call via:, (*7)

php artisan translations:toFile

Takes all entries from the database, generates missing language folders and translation-group files and puts the values to the files., (*8)

NOTE: If you want to call the commands via Artisan::call('translations.toDatabase'), you have to register both commands in app/Console/Kernel.php:, (*9)

protected $commands = [
    // ..  other commands
    \Brotzka\TranslationManager\Module\Console\Commands\TranslationToDatabase::class,
    \Brotzka\TranslationManager\Module\Console\Commands\TranslationToFile::class,
];

Usage

In the back, this package creates two more models (TranslationGroup and Translation) tables (translation_groups and translations)., (*10)

You can use them as you are used to use models in Laravel. The relevant namespace is: Brotzka\TranslationManager\Module., (*11)

You can query relationships like this: - $translation->getParent: returns the parent-instance if existing (NULL if not) - $translation->children: returns all children-instances - $translation->getGroup: returns the translation-group of the current translation - $translationGroup->entries: returns all entries belonging to the current translation-group, (*12)

Future-Plans

  • handle JSON-files
  • provide some GUI-elements (e.g. language-switcher, translation-manager)

The Versions

13/02 2018

dev-master

9999999-dev

Lets you manage your Laravel-translation files via database.

  Sources   Download

MIT

by Fabian Hagen

13/02 2018

v1.1.0

1.1.0.0

Lets you manage your Laravel-translation files via database.

  Sources   Download

MIT

by Fabian Hagen

13/02 2018

dev-commands-patch-1

dev-commands-patch-1

Lets you manage your Laravel-translation files via database.

  Sources   Download

MIT

by Fabian Hagen

13/02 2018

v1.0.5

1.0.5.0

Lets you manage your Laravel-translation files via database.

  Sources   Download

MIT

by Fabian Hagen

12/02 2018

v1.0.2

1.0.2.0

Lets you manage your Laravel-translation files via database.

  Sources   Download

MIT

by Fabian Hagen

12/02 2018

v1.0.1

1.0.1.0

Lets you manage your Laravel-translation files via database.

  Sources   Download

MIT

by Fabian Hagen

07/02 2018

v1.0.0

1.0.0.0

Lets you manage your Laravel-translation files via database.

  Sources   Download

MIT

The Requires

 

by Fabian Hagen