Skip to content
Extraits de code Groupes Projets
Valider c3bcb438 rédigé par sgiehl's avatar sgiehl
Parcourir les fichiers

added api method to get translations for given plugin

parent ae17a26b
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -173,6 +173,39 @@ class API ...@@ -173,6 +173,39 @@ class API
return $languageInfo; return $languageInfo;
} }
/**
* Returns translation strings by language for given plugin
*
* @param string $pluginName name of plugin
* @param string $languageCode ISO language code
* @return array|false Array of arrays, each containing 'label' (translation index) and 'value' (translated string); false if language unavailable
*/
public function getPluginTranslationsForLanguage($pluginName, $languageCode)
{
if (!$this->isLanguageAvailable($languageCode)) {
return false;
}
$languageFile = PIWIK_INCLUDE_PATH . "/plugins/$pluginName/lang/$languageCode.json";
if (!file_exists($languageFile)) {
return false;
}
$data = file_get_contents($languageFile);
$translations = json_decode($data, true);
$languageInfo = array();
foreach ($translations as $module => $keys) {
foreach($keys as $key => $value) {
$languageInfo[] = array(
'label' => sprintf("%s_%s", $module, $key),
'value' => $value
);
}
}
return $languageInfo;
}
/** /**
* Returns the language for the user * Returns the language for the user
* *
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter