]> git.mxchange.org Git - hub.git/blobdiff - inc/classes/main/language/class_LanguageSystem.php
Code merge from latest ship-simu code
[hub.git] / inc / classes / main / language / class_LanguageSystem.php
index 35db75c562c4a81abd44dac09078ed656249e1b7..73763676b8289b20d8b2d5b8815e9a5a83a93f6e 100644 (file)
@@ -53,7 +53,7 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage {
                parent::__construct(__CLASS__);
 
                // Set part description
-               $this->setObjectDescription("Sprachsystem");
+               $this->setObjectDescription("Language sub-system");
 
                // Create unique ID number
                $this->createUniqueID();
@@ -66,7 +66,7 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage {
        /**
         * Creates an instance of the class LanguageSystem and prepares it for usage
         *
-        * @param               $basePath               The local base path for all language strings
+        * @param       $basePath               The local base path for all language strings
         * @return      $langInstance   An instance of LanguageSystem
         * @throws      LanguagePathIsEmptyException            If the provided $basePath is empty
         * @throws      InvalidLanguagePathStringException      If $basePath is no string
@@ -101,7 +101,7 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage {
                $langInstance->initLanguageStrings();
 
                // Set language code from default config
-               $langInstance->setLanguageCode(FrameworkConfiguration::getInstance()->readConfig("default_lang"));
+               $langInstance->setLanguageCode(FrameworkConfiguration::getInstance()->readConfig('default_lang'));
 
                // Remember this instance
                self::$thisInstance = $langInstance;
@@ -120,26 +120,37 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage {
        }
 
        /**
-        * Initialize the array-object for all later language strings
+        * Setter for base path
         *
+        * @param               $basePath               The local base path for all templates
         * @return      void
         */
-       public function initLanguageStrings () {
-               $this->langStrings = new FrameworkArrayObject();
+       protected final function setBasePath ($basePath) {
+               // And set it
+               $this->basePath = (string) $basePath;
        }
 
        /**
-        * Setter for base path
+        * Setter for language code
         *
-        * @param               $basePath               The local base path for all templates
+        * @param               $langCode               The language code for the current application
         * @return      void
         */
-       public final function setBasePath ($basePath) {
+       protected final function setLanguageCode ($langCode) {
                // Cast it
-               $basePath = (string) $basePath;
+               $langCode = (string) $langCode;
 
-               // And set it
-               $this->basePath = $basePath;
+               // And set it (only 2 chars)
+               $this->langCode = substr($langCode, 0, 2);
+       }
+
+       /**
+        * Initialize the array-object for all later language strings
+        *
+        * @return      void
+        */
+       public function initLanguageStrings () {
+               $this->langStrings = new FrameworkArrayObject();
        }
 
        /**
@@ -152,17 +163,25 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage {
        }
 
        /**
-        * Setter for language code
+        * Get the plain message from the cache variable for the given message id
         *
-        * @param               $langCode               The language code for the current application
-        * @return      void
+        * @param       $messageId              The message id we shall find in the cache variable
+        * @return      $messageText    The plain message text
         */
-       public final function setLanguageCode ($langCode) {
-               // Cast it
-               $langCode = (string) $langCode;
+       public function getMessage ($messageId) {
+               // Default is missing message text
+               $messageText = sprintf("!%s!",
+                       $messageId
+               );
+
+               // Try to look it up in the cache variable
+               if ($this->langStrings->offsetExists($messageId)) {
+                       // Return the message string
+                       $messageText = $this->langStrings->offsetGet($messageId);
+               }
 
-               // And set it (only 2 chars)
-               $this->langCode = substr($langCode, 0, 2);
+               // Return the text
+               return $messageText;
        }
 }