X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Flanguage%2Fclass_LanguageSystem.php;h=befccdb1414a132c9a7dbc30dc3a8efef6617cb6;hb=ddac7be24465ecb1d885b3686a3037f10e2aec46;hp=c9bf64d9977ba327a0dd0e3072a3ed69b6c22ad9;hpb=ff66822b5fb6a92f5dc8af55290ecb89ec7f1aaf;p=shipsimu.git diff --git a/inc/classes/main/language/class_LanguageSystem.php b/inc/classes/main/language/class_LanguageSystem.php index c9bf64d..befccdb 100644 --- a/inc/classes/main/language/class_LanguageSystem.php +++ b/inc/classes/main/language/class_LanguageSystem.php @@ -4,9 +4,10 @@ * application and whole framework * * @author Roland Haeder - * @version 0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,7 +20,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage { /** @@ -43,19 +44,13 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage { private static $thisInstance = null; /** - * Private constructor + * Protected constructor * * @return void */ - private final function __construct () { + protected function __construct () { // Call parent constructor - parent::constructor(__CLASS__); - - // Set part description - $this->setPartDescr("Sprachsystem"); - - // Create unique ID number - $this->createUniqueID(); + parent::__construct(__CLASS__); // Clean up a little $this->removeNumberFormaters(); @@ -65,7 +60,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 @@ -100,7 +95,7 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage { $langInstance->initLanguageStrings(); // Set language code from default config - $langInstance->setLanguageCode($langInstance->getConfigInstance()->readConfig("default_lang")); + $langInstance->setLanguageCode(FrameworkConfiguration::getInstance()->readConfig('default_lang')); // Remember this instance self::$thisInstance = $langInstance; @@ -119,26 +114,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("FakedLanguageStrings"); } /** @@ -151,17 +157,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; } }