diff --git a/resources/classes/text.php b/resources/classes/text.php index a75cd66d25..dde808d80f 100644 --- a/resources/classes/text.php +++ b/resources/classes/text.php @@ -11,7 +11,6 @@ class text { * Called when the object is created */ public function __construct() { - //get the list of languages that are available if (file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/translate")) { include("app/translate/translate_include.php"); } @@ -29,27 +28,33 @@ class text { /** * Get a specific item from the cache - * @var string $path examples: app/exec or core/domains + * @var string $language_code examples: en-us, es-cl, fr-fr, pt-pt + * @var string $app_path examples: app/exec or core/domains */ - public function get($path) { + public function get($language_code = null, $app_path = null) { //get the app_languages.php - if (strlen($path) > 0) { - require_once glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/".$path."/app_{languages}.php",GLOB_BRACE); + if (isset($app_path)) { + require_once glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/".$app_path."/app_{languages}.php",GLOB_BRACE); } else { require_once getcwd().'/app_languages.php'; } //add multi-lingual support - foreach($text as $key => $value) { - $text[$key] = $value[$_SESSION['domain']['language']['code']]; + if ($language_code != 'all') { + foreach($text as $key => $value) { + if ($language_code == null) { + $text[$key] = $value[$_SESSION['domain']['language']['code']]; + } + else { + $text[$key] = $value[$language_code]; + } + } } //return the array of translations return $text; - } - } ?> \ No newline at end of file