novius/laravel-translation-loader

Store your language lines in the database, yaml or other sources

v2.1.0 2021-05-06 13:30 UTC

This package is not auto-updated.

Last update: 2021-11-18 16:17:04 UTC


README

Travis Packagist Release Licence

This package is an adaptation of spatie/laravel-translation-loader

WARNING: this package is currently in development.

Features added

  • Translations namespace compatibility ;
  • Console commands to synchronise translations from files to DB;

Requirements

  • PHP >= 8.0
  • Laravel Framework >= 7.0

NOTE: These instructions are for Laravel >= 7.0. If you are using prior version, please see the previous version's docs.

Installation

composer require novius/laravel-translation-loader:dev-master

In config/app.php (Laravel) or bootstrap/app.php (Lumen) you should replace Laravel's translation service provider

Illuminate\Translation\TranslationServiceProvider::class,

by the one included in this package:

Novius\TranslationLoader\TranslationServiceProvider::class,

You must publish and run the migrations to create the language_lines table:

php artisan vendor:publish --provider="Novius\TranslationLoader\TranslationServiceProvider" --tag="migrations"
php artisan migrate

Publish languages files:

php artisan vendor:publish --provider="Novius\TranslationLoader\TranslationServiceProvider" --tag="lang"

Optionally you could publish the config file using this command.

php artisan vendor:publish --provider="Novius\TranslationLoader\TranslationServiceProvider" --tag="config"

Note: publishing assets doesn't work out of the box in Lumen. Instead you have to copy the files from the repo.

Commands

# Synchronise translations from files to DB
php artisan translations:sync

# Clear DB translations + re-import them
php artisan translations:reset

Lint

Run php-cs with:

composer run-script lint

Contributing

Contributions are welcome! Leave an issue on Github, or create a Pull Request.

Licence

This package is under MIT Licence.