v1.0.0
1.0.0.0Lets you manage your Laravel-translation files via database.
MIT
The Requires
by Fabian Hagen
Lets you manage your Laravel-translation files via database.
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)
config/app.php
and re-run php artisan translations:toDatabse
, make your translations and run php artisan translations:toFile
composer require brotzka/translation-manager
config/app.php
:
'available_locales' => ['de', 'en', 'sv'],
php artisan migrate
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)
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, ];
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)
Lets you manage your Laravel-translation files via database.
MIT