Craftable

Admin Translations

Admin Translations is a translation manager package. It scans your codebase and stores all the translations in the database. Once stored it provides nice UI to manage stored translations. It defines a custom translation loader overriding default Laravel's one, so the translations are automatically loaded from the database.

Admin Translations ready to use

Admin Translations edit form

It's heavily inspired by spatie/laravel-translation-loader, which we originally wanted to use, but we were missing some important features (support for translation namespaces etc.). We have also inspired by themsaid/laravel-langman with the scanning process.


Usage

Navigate your browser to the /admin/translations and you should be able to see the translations manager.

If you don't see any translations, start with scanning the directories - click Re-scan translations button. By default app and resources/views folders are scanned (you can change this in the config admin-translations.scanned_directories):

This is going to look your at your codebase and search for used translations (in all .php files). It supports these methods of retrieving the translations:

  • trans()
  • trans_choice()
  • __()
  • Lang::get()
  • Lang::choice()
  • Lang::trans()
  • Lang::transChoice()
  • Lang::getFromJson()
  • @lang()
  • @choice()

It automatically stores all new translations and it also soft-deletes all unused translations (they will be restored once they pop in again in your codebase).

Once scanned and saved manager is ready to use and you can edit any translation for every locale your application uses.

{info} You probably want to add command php artisan admin-translations:scan-and-save to your build process to automatically re-scan the codebase with every deploy.

Translations Export

Admin Translations provides the ability to export data in selected languages as .xlsx file as shown bellow.

Admin Translations export example

Translations Import

Admin Translations provides the ability to import data in selected language from .xlsx file.

{warning} Imported file must have identical structure as generated in Translations export.

If you check Do not override existing translations option only new translations will be imported. Otherwise if your import file contains conflicts with current version of translations, the import will ask you to resolve conflicts to choose which version of translations you want to store.

Admin Translations import example

Admin Translations conflicts example