mergeTranslationArray($translations); $this->setLocale(); $this->englishLanguageLoaded = true; } public function loadUserTranslation() { $language = $this->getLanguageToLoad(); if($language === 'en' && $this->englishLanguageLoaded) { return; } require PIWIK_INCLUDE_PATH . '/lang/' . $language . '.php'; $this->mergeTranslationArray($translations); $this->setLocale(); } public function mergeTranslationArray($translation) { if(!isset($GLOBALS['Piwik_translations'])) { $GLOBALS['Piwik_translations'] = array(); } // we could check that no string overlap here $GLOBALS['Piwik_translations'] = array_merge($GLOBALS['Piwik_translations'], array_filter($translation, 'strlen')); } /** * @return string the language filename prefix, eg 'en' for english * @throws exception if the language set is not a valid filename */ public function getLanguageToLoad() { static $language = null; if(!is_null($language)) { return $language; } Piwik_PostEvent('Translate.getLanguageToLoad', $language); if(is_null($language) || empty($language)) { $language = Zend_Registry::get('config')->General->default_language; } if( Piwik_Common::isValidFilename($language)) { return $language; } else { throw new Exception("The language selected ('$language') is not a valid language file "); } } /** * Generate javascript translations array * * @return string containing javascript code with translations array (including