Language base path is now optional.
authorRoland Haeder <roland@mxchange.org>
Mon, 23 Mar 2015 23:56:49 +0000 (00:56 +0100)
committerRoland Haeder <roland@mxchange.org>
Mon, 23 Mar 2015 23:56:49 +0000 (00:56 +0100)
Signed-off-by: Roland Häder <roland@mxchange.org>
inc/classes/main/language/class_LanguageSystem.php

index c621c57cf5f8c8df71858972a17fe909d9d8f2eb..ec094c9eef6ca37bc2438fd481fa759cc006183e 100644 (file)
@@ -56,7 +56,7 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage,
        /**
         * Creates an instance of the class LanguageSystem and prepares it for usage
         *
        /**
         * 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
         * @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
         */
         * @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();
 
                // 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
                // Is the base path valid?
                if (empty($languageBasePath)) {
                        // Language path is empty