laravel-vue-i18n-generator icon indicating copy to clipboard operation
laravel-vue-i18n-generator copied to clipboard

'Excludes' doesn't work for directories.

Open aezur opened this issue 5 years ago • 8 comments

Assuming a directory structure of:

- lang
    - en
        - file_name_1.php
        - directory_name
            - file_name_2.php

And in the config file:

'excludes' => [
        'file_name_1',    /* Works */
        "directory_name",    /* Doesn't work */
    ],

When art vue-i18n:generate is run, then everything inside directory_name will be included in the output file.

Placing directory_name/file_name_2' into the excludes` array is a workaround, but it doesn't suit my use case.

aezur avatar Jun 25 '19 14:06 aezur

See #81

martinlindhe avatar Jun 25 '19 14:06 martinlindhe

Thanks for the reply, but it doesn't address my issue. I have defined my root folder. The comment of the excludes array states you can add directories to the array to exclude them. You cannot. This feature does not work. EDIT: The desired behaviour is that when the path to a directory is added to the excludes array, that directory and the files it contains are excluded from the output of art vue-i18n:generate.

aezur avatar Jul 08 '19 08:07 aezur

Alright, thanks for letting me know

martinlindhe avatar Jul 08 '19 09:07 martinlindhe

Looking at the source code (https://github.com/martinlindhe/laravel-vue-i18n-generator/blob/master/src/Generator.php#L56) the generator will only compare filenames ignoring the folder path.
So if you wanted to exclude file_name_2.php you could just add file_name_2 to your excludes array as a workaround.

octfx avatar Jul 10 '19 10:07 octfx

I'm not working on this code atm, but you are very welcome to submit a PR to fix this.

martinlindhe avatar Jul 10 '19 15:07 martinlindhe

Hi @martinlindhe , do you have any guidelines for PRs?

karolispx avatar Aug 29 '19 12:08 karolispx

@karolispx nothing special, just open a PR and we take it from there!

martinlindhe avatar Aug 29 '19 12:08 martinlindhe

I took a quick look at this and the code at https://github.com/martinlindhe/laravel-vue-i18n-generator/blob/master/src/Generator.php#L56 is used to exclude directories inside 'resources/lang/' directory, i.e. if you had a few languages: en, ko, ru - you could exclude the whole language directory by adding the folder name to 'excludes' at https://github.com/martinlindhe/laravel-vue-i18n-generator/blob/master/src/config/vue-i18n-generator.php#L41, i.e. 'excludes' => ['ko'],

The actual problem is not being able to exclude directory from a language folder, i.e. excluding directory '/resources/lang/en/custom' does not work.

This function https://github.com/martinlindhe/laravel-vue-i18n-generator/blob/master/src/Generator.php#L259 handles file exclusion so I think appropriatefunction needs to be written for excluding directories and called here https://github.com/martinlindhe/laravel-vue-i18n-generator/blob/master/src/Generator.php#L215

Will take a closer look when I have some time.

karolispx avatar Aug 30 '19 13:08 karolispx