From bf0716bfb6ef4128973d5dd211dac02490ab86a5 Mon Sep 17 00:00:00 2001 From: mattpiwik Date: Mon, 9 Jun 2008 00:44:10 +0000 Subject: - adding 7 new translations: german, spanish, italian, russian, ukranian, catalan, dutch - translations fallback to english by default (customizable in config file) - adding a few strings that weren't translatable before - 'translationAvailable' plugin information entry is now optional (defaults to false) refs #251 git-svn-id: http://dev.piwik.org/svn/trunk@518 59fd770c-687e-43c8-a1e3-f5a4ff64c105 --- modules/Translate.php | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'modules/Translate.php') diff --git a/modules/Translate.php b/modules/Translate.php index ec10daddff..63e99810ce 100644 --- a/modules/Translate.php +++ b/modules/Translate.php @@ -10,7 +10,6 @@ */ /** - * * @package Piwik */ class Piwik_Translate @@ -33,26 +32,31 @@ class Piwik_Translate } private function __construct() - { - $GLOBALS['Piwik_translations'] = array(); - + { + $translations = array(); + + $language = $this->getFallbackLanguageToLoad(); + require_once "lang/" . $language .".php"; + $this->addTranslationArray($translations); + $language = $this->getLanguageToLoad(); - - $translations = array(); require_once "lang/" . $language .".php"; - - $this->addTranslationArray($translations); + $this->addTranslationArray($translations); + + setlocale(LC_ALL, $GLOBALS['Piwik_translations']['General_Locale']); } public function addTranslationArray($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'], $translation); } /** - * Enter description here... - * * @return string the language filename prefix, eg "en" for english * @throws exception if the language set in the config file is not a valid filename */ @@ -68,6 +72,11 @@ class Piwik_Translate { throw new Exception("The language selected ('$language') is not a valid language file "); } + } + + protected function getFallbackLanguageToLoad() + { + return Zend_Registry::get('config')->Language->fallback; } /** -- cgit v1.2.3