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
path: root/core
diff options
context:
space:
mode:
authorMatthieu Napoli <matthieu@mnapoli.fr>2014-12-30 02:32:32 +0300
committerMatthieu Napoli <matthieu@mnapoli.fr>2015-01-05 05:25:11 +0300
commitea9c95410a436cea3051ab813476c24b4ddaca0d (patch)
tree2ba9b6e9904d7046b4dc08c34dea5205cf5c5627 /core
parentde06fd66ee7d01832ff08f13d58e21a9d7a510c7 (diff)
Fix unit tests by loading no translations by default in tests
Diffstat (limited to 'core')
-rw-r--r--core/Intl/Locale.php19
-rw-r--r--core/Translate.php5
-rw-r--r--core/Translation/Translator.php10
3 files changed, 33 insertions, 1 deletions
diff --git a/core/Intl/Locale.php b/core/Intl/Locale.php
new file mode 100644
index 0000000000..7c18b727c5
--- /dev/null
+++ b/core/Intl/Locale.php
@@ -0,0 +1,19 @@
+<?php
+
+namespace Piwik\Intl;
+
+class Locale
+{
+ public static function setLocale($locale)
+ {
+ $localeVariant = str_replace('UTF-8', 'UTF8', $locale);
+
+ setlocale(LC_ALL, $locale, $localeVariant);
+ setlocale(LC_CTYPE, '');
+ }
+
+ public static function setDefaultLocale()
+ {
+ self::setLocale('en_US.UTF-8');
+ }
+}
diff --git a/core/Translate.php b/core/Translate.php
index 70f795245b..c828ed3d1d 100644
--- a/core/Translate.php
+++ b/core/Translate.php
@@ -31,10 +31,12 @@ class Translate
public static function loadEnglishTranslation()
{
+ self::loadCoreTranslation();
}
public static function unloadEnglishTranslation()
{
+ self::getTranslator()->reset();
}
public static function reloadLanguage($language = false)
@@ -49,6 +51,7 @@ class Translate
*/
public static function loadCoreTranslation($language = false)
{
+ self::getTranslator()->addDirectory(PIWIK_INCLUDE_PATH . '/lang');
}
public static function mergeTranslationArray($translation)
@@ -67,7 +70,7 @@ class Translate
/** Reset the cached language to load. Used in tests. */
public static function reset()
{
- self::getTranslator()->setCurrentLanguage(null);
+ self::getTranslator()->reset();
}
/**
diff --git a/core/Translation/Translator.php b/core/Translation/Translator.php
index 7233882cd6..9d256b6940 100644
--- a/core/Translation/Translator.php
+++ b/core/Translation/Translator.php
@@ -178,6 +178,16 @@ class Translator
}
/**
+ * Should be used by tests only, and this method should eventually be removed.
+ */
+ public function reset()
+ {
+ $this->currentLanguage = $this->getDefaultLanguage();
+ $this->directories = array();
+ $this->translations = array();
+ }
+
+ /**
* @param string $translation
* @return null|string
*/