Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'core/Translate.php')
-rw-r--r--core/Translate.php26
1 files changed, 20 insertions, 6 deletions
diff --git a/core/Translate.php b/core/Translate.php
index 9d4b3a3efb..adc3379cf4 100644
--- a/core/Translate.php
+++ b/core/Translate.php
@@ -47,8 +47,12 @@ class Piwik_Translate
{
return;
}
-
- require PIWIK_INCLUDE_PATH . '/lang/' . $language . '.php';
+ $path = PIWIK_INCLUDE_PATH . '/lang/' . $language . '.php';
+ if(!is_readable($path))
+ {
+ throw new Exception(Piwik_TranslateException('General_ExceptionLanguageFileNotFound', array($language)));
+ }
+ require $path;
$this->mergeTranslationArray($translations);
$this->setLocale();
}
@@ -74,9 +78,11 @@ class Piwik_Translate
{
return $language;
}
+
Piwik_PostEvent('Translate.getLanguageToLoad', $language);
- if(is_null($language) || empty($language))
+ $language = Piwik_Common::getRequestVar('language', is_null($language) ? '' : $language, 'string');
+ if(empty($language))
{
$language = Zend_Registry::get('config')->General->default_language;
}
@@ -110,7 +116,7 @@ class Piwik_Translate
$moduleRegex .= $module.'|';
}
$moduleRegex = substr($moduleRegex, 0, -1);
- $moduleRegex .= ')_([^_]+)_js$#i';
+ $moduleRegex .= ')_.*_js$#i';
foreach($GLOBALS['Piwik_translations'] as $key => $value)
{
@@ -124,14 +130,22 @@ class Piwik_Translate
'for(var i in translations) { piwik_translations[i] = translations[i];} ';
$js .= 'function _pk_translate(translationStringId) { '.
'if( typeof(piwik_translations[translationStringId]) != \'undefined\' ){ return piwik_translations[translationStringId]; }'.
- 'return "The string "+translationStringId+" was not loaded in javascript. Make sure it is prefixed with _js";}';
+ 'return "The string "+translationStringId+" was not loaded in javascript. Make sure it is suffixed with _js and that you called {loadJavascriptTranslations plugins=\'\$YOUR_PLUGIN_NAME\'} before your javascript code.";}';
return $js;
}
+ /**
+ * Set locale
+ *
+ * @see http://php.net/setlocale
+ */
private function setLocale()
{
- setlocale(LC_ALL, $GLOBALS['Piwik_translations']['General_Locale']);
+ $locale = $GLOBALS['Piwik_translations']['General_Locale'];
+ $locale_variant = str_replace('UTF-8', 'UTF8', $locale);
+ setlocale(LC_ALL, $locale, $locale_variant);
+ setlocale(LC_CTYPE, '');
}
}