martinlindhe / laravel-vue-i18n-generator

Generates a vue-i18n compatible include file from your Laravel translations
MIT License
306 stars 207 forks source link

Having JSON and Array translations at the same time #85

Open lk77 opened 5 years ago

lk77 commented 5 years ago

Hello,

i seems that it's not possible to have json translations and array translations at the same time, when using --multi-locales option.

In Generator.php line 75 :

if ($fileinfo->isDir()) {
                    $local = $this->allocateLocaleArray($fileinfo->getRealPath());
                } else {
                    $local = $this->allocateLocaleJSON($fileinfo->getRealPath());
                    if ($local === null) continue;
                }

if the locale exist as a directory, then the json translation is never applied.

thanks.

martinlindhe commented 5 years ago

Could you give an example?

How does your directory structure look, please provide output of tree command.

What is the expected result, versus actual result?

lk77 commented 5 years ago

There is the tree output :

├── en │   ├── auth.php │   ├── pagination.php │   ├── passwords.php │   └── validation.php ├── fr │   ├── auth.php │   ├── pagination.php │   ├── passwords.php │   └── validation.php └── fr.json

the expected result is the inclusion of the translations in fr.json in the final fr.js generated in resources/assets/js/langs/fr.js, which is not the case.

Only the translations in the *.php files are included.

If i don't use --multi-locales options, translations from fr.js are correctly included

"fr": {
        "I love programming.": "J'aime programmer",
        "pagination": {
            "previous": "« Précédent",
            "next": "Suivant »"
        },
[...]

with --multi-locales option :

"fr": {
        "pagination": {
            "previous": "« Précédent",
            "next": "Suivant »"
        },
murrant commented 4 years ago

This should be fixed by #96

lk77 commented 4 years ago

Thanks !

lk77 commented 4 years ago

Hello,

i reopen the issue since #96 was reverted.

@martinlindhe