Skip to content

Commit

Permalink
Log a proper warning when an unexected translation key is added to cl…
Browse files Browse the repository at this point in the history
…ient side translations (matomo-org#22855)
  • Loading branch information
sgiehl authored and valentinab25 committed Jan 27, 2025
1 parent c82f93f commit 20fa47e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/Translation/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
namespace Piwik\Translation;

use Piwik\Config;
use Piwik\Container\StaticContainer;
use Piwik\Log\LoggerInterface;
use Piwik\Piwik;
use Piwik\Translation\Loader\LoaderInterface;

Expand Down Expand Up @@ -199,6 +201,13 @@ public function getJavascriptTranslations()
{
$clientSideTranslations = array();
foreach ($this->getClientSideTranslationKeys() as $id) {
if (strpos($id, '_') === false) {
StaticContainer::get(LoggerInterface::class)->warning(
'Unexpected translation key found in client side translations: {translation_key}',
['translation_key' => $id]
);
continue;
}
[$plugin, $key] = explode('_', $id, 2);
$clientSideTranslations[$id] = $this->decodeEntitiesSafeForHTML($this->getTranslation($id, $this->currentLanguage, $plugin, $key));
}
Expand Down

0 comments on commit 20fa47e

Please sign in to comment.