inpsyde / wp-translation-downloader

Composer plugin to download WordPress translations
MIT License
45 stars 3 forks source link

Allow installation of translations from a local directory #12

Closed jenkoian closed 2 years ago

jenkoian commented 3 years ago

Is your feature request related to a problem? Please describe. We are using MLP 3.0 and thus the translations listed on https://api.wordpress.org/translations/plugins/1.0/?slug=multilingual-press are not the same. The translations are available within the languages directory of the plugin (so in wp-content/plugins/multilingualpress/languages). As far as I can tell, there's no way to install these translations.

Describe the solution you'd like It would be nice to be able to give wp-translation-downloader a file path, similarly to how you can pass custom API endpoints.

Describe alternatives you've considered Well, it's possible I'm misunderstanding something and multilingualpress's translations get loaded implicitly, but I couldn't find a call to load_plugin_textdomain anywhere in the plugin so I'm not sure.

Additional context

Chrico commented 3 years ago

Sorry for the very very late response (☕ ).

It sounds to me like a good idea to have a local path instead of an API-Endpoint to maybe fetch translations. But first of all i'd like to give this ticket @danielhuesken for further clarification regarding the behavior of MLP.

danielhuesken commented 3 years ago

@jenkoian In MLP 3 we add translations directly form our system on every release. But you'er right we not have load_plugin_textdomain in MLP. Will will fix it in the next release.

danielhuesken commented 3 years ago

@jenkoian Sorry, now i see that we use load_text_domain() in MLP directly to prevent problems with the version on wp.org.

jenkoian commented 3 years ago

That makes sense, I can see that now. I still feel a way to install translations from a local directory would be useful, but you can close this now if you'd prefer. Thanks.

Chrico commented 3 years ago

Hey ☕

I need to re-think this issue. wp-translation-downloader is meant to be used on deployment or while working locally with WordPress. It tries to download for all configured languages from a GlotPress endpoint for each listed dependency in composer.json the translations files.

It is not meant to solve how a Plugin, Theme or Library are loading translations. WordPress has for this an API which automatically first checks the WP_LANG_DIR for translations and if not matching it falls back to the given path from each load_*_textdomain()-function. If you want to change the loading behavior, you can either change the WP_LANG_DIR constant, hook into load_textdomain_mofile-filter to change the path to the .mo-file or you can just not download the translation files via wp-translation-downloader and use one of the previous options (constant or hook) to load local translation files.