Browse Source

Update classes/text.php

Mark Crane 10 years ago
parent
commit
487d50077c
1 changed files with 14 additions and 9 deletions
  1. 14 9
      resources/classes/text.php

+ 14 - 9
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;
-
 	}
-
 }
 
 ?>