vsch / laravel-translation-manager

Enhanced Management of Laravel 4 & 5 Translations, with Yandex Translation API assisted translations.
MIT License
181 stars 84 forks source link

Translation manager with nwidart/laravel-modules #73

Open maj0rr opened 7 years ago

maj0rr commented 7 years ago

Hey I'm using nwidart/laravel-modules which creates a folder structure like that:

Project_root_dir/Modules/My_Module/Resources/lang/en/user.php default lang files are in Project_root_dir/resources/lang/en/user.php

how do I setup the module lang files in the laravel-translation-manager.php config (language_dirs)?

Thanks for the feedback

vsch commented 7 years ago

@maj0rr, there is no standard mechanism but you can coerce the 'workbench' in 'language_dirs' config to achieve what I think is acceptable:

Change the LTM configuration in the application so that the workbench element is:

        'workbench' => [
            'root' => '/Modules/{package}',
            'files' => 'Resources/lang/{locale}/{group}',
            'include' => '*',
            'vars' => [
                '{vendor}' => 'module',
            ],
        ],

Then when you import all the module language resources will be imported under group names wbn:module.{module}::{group} where {module} will be replaced with the name of the module and {group} will be replaced by the group of the translation files for the module.

A bit of a kludge but I got it to work without needing to modify the package source.

The project root resources handling is standard and does not need modification.

I tested Import and export with this config and two dummy modules with translation files.

image

The en/test.php files were created by me, the ru/test.php were exported after a russian translation was added in LTM.

image

image

image

image

maj0rr commented 7 years ago

Great support @vsch !! Thanks! Works for me at the moment. Maybe you can include module support in the next release :)

Thanks!

vsch commented 7 years ago

@maj0rr, I will add it to the enhancement list. I will keep this issue open until it is implemented.