diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-11-15 20:43:14 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-11-15 20:43:14 -0500 |
commit | 94cd5869bf9e4b86063cbb71777a05525b9d5c52 (patch) | |
tree | 65e6992a365df91262262d095893a7e2f01e6c89 /app/Core/Translator.php | |
parent | ebb6b2827d0496303852f524a551592295dd0040 (diff) |
Do not load translations from a relative path
When the application is installed outside of the
document root, loading translations will not work.
Diffstat (limited to 'app/Core/Translator.php')
-rw-r--r-- | app/Core/Translator.php | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/app/Core/Translator.php b/app/Core/Translator.php index 113c0dc6..ac2e2aae 100644 --- a/app/Core/Translator.php +++ b/app/Core/Translator.php @@ -11,13 +11,6 @@ namespace Kanboard\Core; class Translator { /** - * Locale path - * - * @var string - */ - const PATH = 'app/Locale'; - - /** * Locale * * @static @@ -171,9 +164,13 @@ class Translator * @param string $language Locale code: fr_FR * @param string $path Locale folder */ - public static function load($language, $path = self::PATH) + public static function load($language, $path = '') { - $filename = $path.DIRECTORY_SEPARATOR.$language.DIRECTORY_SEPARATOR.'translations.php'; + if ($path === '') { + $path = self::getDefaultFolder(); + } + + $filename = implode(DIRECTORY_SEPARATOR, array($path, $language, 'translations.php')); if (file_exists($filename)) { self::$locales = array_merge(self::$locales, require($filename)); @@ -190,4 +187,15 @@ class Translator { self::$locales = array(); } + + /** + * Get default locales folder + * + * @access public + * @return string + */ + public static function getDefaultFolder() + { + return implode(DIRECTORY_SEPARATOR, array(__DIR__, '..', 'Locale')); + } } |