wp-cli / i18n-command

Provides internationalization tools for WordPress projects.
MIT License
96 stars 52 forks source link

Include /vendor/ directory translation ready strings #327

Closed maheshwaghmare closed 2 years ago

maheshwaghmare commented 2 years ago

Feature Request

By default the files and folders are always excluded:

- node_modules
- .git
- .svn
- .CVS
- .hg
- vendor
- *.min.js

https://github.com/wp-cli/i18n-command/blob/7d12ddaca073cdc2f3538265d33583186aae27ea/src/MakePotCommand.php#L50

Describe your use case and the problem you are facing

As many developers use the 3rd party packages which have their own text-domains.

E.g. The https://github.com/CMB2/CMB2 is a most common framework which is used by developers.

The package uses the textdomain cmb2.

The strings are not included from the vendor directory while using:

wp i18n make-pot . sample.pot

Describe the solution you'd like

I think while installing the composer dependency if we set the different location than the /vendor/ then the issue may resolve.

But, It varies by developers.

So, I think, if we allow developer to somehow skip the array merge from code:

https://github.com/wp-cli/i18n-command/blob/7d12ddaca073cdc2f3538265d33583186aae27ea/src/MakePotCommand.php#L440-L443

Maybe it'll be another flag like --skip-default-excludes which may skip the default array merge.

swissspidy commented 2 years ago

Previously: #172, #84

--include is supposed to be able to override excludes.

Have you tried something like wp i18n make-pot . --include=vendor/cmb2,\* --ignore-domain?

Otherwise, yeah, changing the installation directory should work as well.

maheshwaghmare commented 2 years ago

Oh! Very quick response.

Thanks for the suggestion. I had tried the --include but it not works.

I have tried the command wp i18n make-pot . --include=vendor/cmb2,\* --ignore-domain but not works.

Let me check few diff. options.

Again thanks for the quick response.

maheshwaghmare commented 2 years ago

With the help of composer/installers, I have move the cmb2/cmb2 to diff. directory.

Sharing the details so, If someone facing the same then it'll help them.

Below is the reference composer.json file:

{
    ..
    "require": {
        "composer/installers": "~1.0",
        "cmb2/cmb2": "^2.7",
            ..
    },
    "extra": {
        "installer-paths": {
            "includes/3rdparty/cmb2/cmb2": ["cmb2/cmb2"],
            ..
        }
    },
    "autoload" : {
        "files": [
            "includes/3rdparty/cmb2/cmb2/init.php",
                    ..
        ]
    },
        ..
}

Here, I have install the cmb2 package into the directory "includes/3rdparty/cmb2/cmb2".


Closing the issue as alternative solution is exist.