matomo-for-wordpress icon indicating copy to clipboard operation
matomo-for-wordpress copied to clipboard

Use WordPress translations system

Open tsteur opened this issue 6 years ago • 1 comments

We could hook into Matomo translations and replace the translations class to use WordPress translations (__('', 'wp-matomo')). This way other WP plugins can hook into it and more importantly we don't need to ship all translations with the plugin see https://make.wordpress.org/polyglots/handbook/rosetta/theme-plugin-directories/#translating-themes-plugins

Basically, through DI we would be replacing Piwik\Translation\Translator class and whenever translate() method is called, that method will be calling __($matomoTranslationKey, 'wp-matomo').

This means we need to generate WP translation files (*.mo/.po) whenever we update Matomo core.

We need to see how this could work for plugins. I suppose for any none core plugin we wouldn't really want to do this and would need to fallback to Matomo logic?

tsteur avatar Oct 08 '19 02:10 tsteur

See https://github.com/matomo-org/wp-matomo/pull/36 started some work of it. It'll be great if we could reduce the release file this way by needing only one language

tsteur avatar Oct 21 '19 03:10 tsteur

Hello @tsteur

I guess with the closed PR, we can close this issue too?

mattmary avatar Oct 04 '22 22:10 mattmary

I think that makes sense for now 👍

tsteur avatar Oct 04 '22 22:10 tsteur