empuxa/laravel-translation-manager

A smart translation manager for Laravel.

v1.0.5 2024-03-15 18:32 UTC

README

Latest Version on Packagist Tests Total Downloads

Banner

This package provides a web interface to manage your Laravel application translations. While the concept is heavily inspired by barryvdh/laravel-translation-manager, this package is a complete rewrite with a different approach to provide a better non-developer user experience:

  • there is a non-editable default language, to separate development from translation
  • it can export to sub-folders: for example, you can now have a lang/en/dashboard/charts.php file
  • all translation strings are on one page, that's based on Tailwind CSS
  • it has (some) tests 🫣

However, currently there are also some disadvantages (feel free to contribute!):

  • it does only read and export PHP files, no JSON
  • vendor translations are not supported
  • since all strings are on one page, big projects might have performance issues

Overview

Installation

This package requires Laravel 9.33+. You can install the package via composer:

composer require empuxa/laravel-translation-manager

Afterward, copy the vendor files:

php artisan vendor:publish --provider="Empuxa\TranslationManager\TranslationManagerServiceProvider"

Finally, run the migrations:

php artisan migrate

Don't forget to also update the config file config/translation-manager.php to your needs!

Usage

Local Storage / Single Server Setup

By default, the translation manager is available at /translation-manager. However, you can change the route in the config file. Before you can edit translations, you must also set up the output languages. The default language isn't editable to separate development and translation.

To push the translations into the database, you need to run the following command:

php artisan translation-manager:push-to-db

It's now possible to edit any language string via the web interface and save them to the database. If a language string already exists, it won't be overwritten. You can force that behavior by using the --force flag.

Before you can use the translations in your application, you need to export them to PHP files that will get stored in the lang folder. You can do that by running the following command:

php artisan translation-manager:pull-from-db

Cloud Storage / Multi Server Setup

The best way to use the translation manager in a cloud setup is to run a single server instance, where the translators can edit the translations. However, you might also want to push the translations to other environments. That's where cloud storage comes into play.

By using the translation-manager:push-to-storage command, you can push any lang file to the storage disk defined in the config. With the translation-manager:pull-from-storage command, you can then pull the translations from the storage disk.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.