X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Flanguage%2Fclass_LanguageSystem.php;h=ec094c9eef6ca37bc2438fd481fa759cc006183e;hp=e6bfa77f5fcd8696070c804b2018e378b918dae3;hb=33d78ab1bd06187507bc28140e193d2484518e6a;hpb=1ee35e6d96c456b8e3499bd683f1647aa28bd501 diff --git a/inc/classes/main/language/class_LanguageSystem.php b/inc/classes/main/language/class_LanguageSystem.php index e6bfa77f..ec094c9e 100644 --- a/inc/classes/main/language/class_LanguageSystem.php +++ b/inc/classes/main/language/class_LanguageSystem.php @@ -5,7 +5,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team * @license GNU GPL 3.0 or any newer version * @link http://www.shipsimu.org * @@ -56,7 +56,7 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage, /** * Creates an instance of the class LanguageSystem and prepares it for usage * - * @param $languageBasePath The local base path for all language strings + * @param $languageBasePath The local base path for all language strings or emty for auto-detection * @return $langInstance An instance of LanguageSystem * @throws LanguagePathIsEmptyException If the provided $languageBasePath is empty * @throws InvalidLanguagePathStringException If $languageBasePath is no string @@ -65,10 +65,23 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage, * @throws LanguagePathReadProtectedException If $languageBasePath is * read-protected */ - public static final function createLanguageSystem ($languageBasePath) { + public static final function createLanguageSystem ($languageBasePath = '') { // Get a new instance $langInstance = new LanguageSystem(); + // Is the base path set? + if (empty($languageBasePath)) { + // No, then attempt "auto-dection": + // 1) Get application + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + // 2) Try to build it + $languageBasePath = sprintf('%sapplication/%s/language/', + $langInstance->getConfigInstance()->getConfigEntry('base_path'), + $applicationInstance->getAppShortName() + ); + } // END - if + // Is the base path valid? if (empty($languageBasePath)) { // Language path is empty @@ -140,7 +153,7 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage, * @return void */ public function initLanguageStrings () { - $this->langStrings = new FrameworkArrayObject("FakedLanguageStrings"); + $this->langStrings = new FrameworkArrayObject('FakedLanguageStrings'); } /** @@ -160,7 +173,7 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage, */ public function getMessage ($messageId) { // Default is missing message text - $messageText = sprintf("!%s!", + $messageText = sprintf('!%s!', $messageId ); @@ -168,7 +181,7 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage, if ($this->langStrings->offsetExists($messageId)) { // Return the message string $messageText = $this->langStrings->offsetGet($messageId); - } + } // END - if // Return the text return $messageText;