Hello, I hope that this is the right place to ask. I want to be able to override the translations within my plugin. During my research I already found this GitHub issue here (Using own translations · Issue #8160 · matomo-org/matomo · GitHub), but it seems like the solution described there is already outdated. I looked around in the existing code-base and found an existing dependency injection (within config/environment/dev
) which looks like following:
return array(
'Piwik\Cache\Backend' => DI\object('Piwik\Cache\Backend\ArrayCache'),
'Piwik\Translation\Loader\LoaderInterface' => DI\object('Piwik\Translation\Loader\LoaderCache')
->constructor(DI\get('Piwik\Translation\Loader\DevelopmentLoader')),
'Piwik\Translation\Loader\DevelopmentLoader' => DI\object()
->constructor(DI\get('Piwik\Translation\Loader\JsonFileLoader')),
);
I’ve following code within my plugins config.php
<?php
return array(
'Piwik\Translation\Loader\LoaderInterface' => DI\object('Piwik\Translation\Loader\LoaderCache')->constructor(DI\get('Piwik\Plugins\MyPlugin\CustomTranslationLoader')),
'Piwik\Plugins\MyPlugin\CustomTranslationLoader' => DI\object()->constructor(DI\get('Piwik\Translation\Loader\JsonFileLoader')),
);
CustomTranslationLoader looks like that:
namespace Piwik\Plugins\MyPlugin;
class CustomTranslationLoader implements \Piwik\Translation\Loader\LoaderInterface
{
/**
* Basically I copied the DevelopmentLoader
*/
}
Unfortunately it seems like this won’t work out. Is there anything else I’ve to consider?
Thank you!