diff --git a/administrator/components/com_languages/controllers/installed.php b/administrator/components/com_languages/controllers/installed.php index b9c4e7441f947..b58cc4bc8e858 100644 --- a/administrator/components/com_languages/controllers/installed.php +++ b/administrator/components/com_languages/controllers/installed.php @@ -67,8 +67,14 @@ public function switchAdminLanguage() $cid = $this->input->get('cid', ''); $model = $this->getModel('installed'); - // Fetching the language name from the xx-XX.xml + // Fetching the language name from the xx-XX.xml or langmetadata.xml respectively. $file = JPATH_ADMINISTRATOR . '/language/' . $cid . '/' . $cid . '.xml'; + + if (!is_file($file)) + { + $file = JPATH_ADMINISTRATOR . '/language/' . $cid . '/langmetadata.xml'; + } + $info = JInstaller::parseXMLInstallFile($file); $languageName = $info['name']; diff --git a/installation/model/languages.php b/installation/model/languages.php index fe7d7116a12b6..25f77c92937cf 100644 --- a/installation/model/languages.php +++ b/installation/model/languages.php @@ -313,7 +313,13 @@ protected function getInstalledlangs($cms_client = 'administrator') foreach ($langlist as $lang) { - $file = $path . '/' . $lang . '/' . $lang . '.xml'; + $file = $path . '/' . $lang . '/' . $lang . '.xml'; + + if (!is_file($file)) + { + $file = $path . '/' . $lang . '/langmetadata.xml'; + } + $info = JInstaller::parseXMLInstallFile($file); $row = new stdClass; $row->language = $lang; diff --git a/libraries/src/Installer/Adapter/LanguageAdapter.php b/libraries/src/Installer/Adapter/LanguageAdapter.php index f78b26f28480f..436d298b39d8d 100644 --- a/libraries/src/Installer/Adapter/LanguageAdapter.php +++ b/libraries/src/Installer/Adapter/LanguageAdapter.php @@ -313,8 +313,15 @@ protected function _install($cname, $basePath, $clientId, &$element) // Create an unpublished content language. if ((int) $clientId === 0) { + $manifestfile = JPATH_SITE . '/language/' . $this->tag . '/' . $this->tag . '.xml'; + + if (!is_file($manifestfile)) + { + $manifestfile = JPATH_SITE . '/language/' . $this->tag . '/langmetadata.xml'; + } + // Load the site language manifest. - $siteLanguageManifest = LanguageHelper::parseXMLLanguageFile(JPATH_SITE . '/language/' . $this->tag . '/' . $this->tag . '.xml'); + $siteLanguageManifest = LanguageHelper::parseXMLLanguageFile($manifestfile); // Set the content language title as the language metadata name. $contentLanguageTitle = $siteLanguageManifest['name']; @@ -331,7 +338,14 @@ protected function _install($cname, $basePath, $clientId, &$element) // Try to load a language string from the installation language var. Will be removed in 4.0. if ($contentLanguageNativeTitle === $contentLanguageTitle) { - if (file_exists(JPATH_INSTALLATION . '/language/' . $this->tag . '/' . $this->tag . '.xml')) + $manifestfile = JPATH_INSTALLATION . '/language/' . $this->tag . '/' . $this->tag . '.xml'; + + if (!is_file($manifestfile)) + { + $manifestfile = JPATH_INSTALLATION . '/language/' . $this->tag . '/langmetadata.xml'; + } + + if (file_exists($manifestfile)) { $installationLanguage = new Language($this->tag); $installationLanguage->load('', JPATH_INSTALLATION); @@ -831,6 +845,12 @@ public function refreshManifestCache() { $client = ApplicationHelper::getClientInfo($this->parent->extension->client_id); $manifestPath = $client->path . '/language/' . $this->parent->extension->element . '/' . $this->parent->extension->element . '.xml'; + + if (!is_file($manifestPath)) + { + $manifestPath = $client->path . '/language/' . $this->parent->extension->element . '/langmetadata.xml'; + } + $this->parent->manifest = $this->parent->isManifest($manifestPath); $this->parent->setPath('manifest', $manifestPath); $manifest_details = Installer::parseXMLInstallFile($this->parent->getPath('manifest')); diff --git a/libraries/src/Language/Language.php b/libraries/src/Language/Language.php index c0e7fcfa5b658..9d3e2459eb5b9 100644 --- a/libraries/src/Language/Language.php +++ b/libraries/src/Language/Language.php @@ -203,6 +203,7 @@ public function __construct($lang = null, $debug = false) // Note: Manual indexing to enforce load order. $paths[0] = JPATH_SITE . "/language/overrides/$lang.localise.php"; $paths[2] = JPATH_SITE . "/language/$lang/$lang.localise.php"; + $paths[4] = JPATH_SITE . "/language/$lang/localise.php"; } if (defined('JPATH_ADMINISTRATOR')) @@ -210,6 +211,7 @@ public function __construct($lang = null, $debug = false) // Note: Manual indexing to enforce load order. $paths[1] = JPATH_ADMINISTRATOR . "/language/overrides/$lang.localise.php"; $paths[3] = JPATH_ADMINISTRATOR . "/language/$lang/$lang.localise.php"; + $paths[5] = JPATH_ADMINISTRATOR . "/language/$lang/localise.php"; } ksort($paths); @@ -713,43 +715,41 @@ public function load($extension = 'joomla', $basePath = JPATH_BASE, $lang = null $path = LanguageHelper::getLanguagePath($basePath, $lang); $internal = $extension == 'joomla' || $extension == ''; - $filename = $internal ? $lang : $lang . '.' . $extension; - $filename = "$path/$filename.ini"; - if (isset($this->paths[$extension][$filename]) && !$reload) + $filenames = array(); + + if ($internal) { - // This file has already been tested for loading. - $result = $this->paths[$extension][$filename]; + $filenames[] = "$path/$lang.ini"; + $filenames[] = "$path/joomla.ini"; } else { - // Load the language file - $result = $this->loadLanguage($filename, $extension); + // Try first with a language-prefixed filename. + $filenames[] = "$path/$lang.$extension.ini"; + $filenames[] = "$path/$extension.ini"; + } - // Check whether there was a problem with loading the file - if ($result === false && $default) + foreach ($filenames as $filename) + { + if (isset($this->paths[$extension][$filename]) && !$reload) { - // No strings, so either file doesn't exist or the file is invalid - $oldFilename = $filename; - - // Check the standard file name - if (!$this->debug) - { - $path = LanguageHelper::getLanguagePath($basePath, $this->default); - - $filename = $internal ? $this->default : $this->default . '.' . $extension; - $filename = "$path/$filename.ini"; + // This file has already been tested for loading. + $result = $this->paths[$extension][$filename]; + } + else + { + // Load the language file + $result = $this->loadLanguage($filename, $extension); + } - // If the one we tried is different than the new name, try again - if ($oldFilename != $filename) - { - $result = $this->loadLanguage($filename, $extension, false); - } - } + if ($result) + { + return true; } } - return $result; + return false; } /** diff --git a/libraries/src/Language/LanguageHelper.php b/libraries/src/Language/LanguageHelper.php index e4867895d7c62..e0195aa8be0f7 100644 --- a/libraries/src/Language/LanguageHelper.php +++ b/libraries/src/Language/LanguageHelper.php @@ -233,6 +233,11 @@ public static function getInstalledLanguages($clientId = null, $processMetaData $clientPath = (int) $language->client_id === 0 ? JPATH_SITE : JPATH_ADMINISTRATOR; $metafile = self::getLanguagePath($clientPath, $language->element) . '/' . $language->element . '.xml'; + if (!is_file($metafile)) + { + $metafile = self::getLanguagePath($clientPath, $language->element) . '/langmetadata.xml'; + } + // Process the language metadata. if ($processMetaData) { @@ -546,7 +551,13 @@ public static function exists($lang, $basePath = JPATH_BASE) */ public static function getMetadata($lang) { - $file = self::getLanguagePath(JPATH_BASE, $lang) . '/' . $lang . '.xml'; + $file = self::getLanguagePath(JPATH_BASE, $lang) . '/' . $lang . '.xml'; + + if (!is_file($file)) + { + $file = self::getLanguagePath(JPATH_BASE, $lang) . '/langmetadata.xml'; + } + $result = null; if (is_file($file)) @@ -613,6 +624,11 @@ public static function parseLanguageFiles($dir = null) $dirPathParts = pathinfo($directory); $file = $directory . '/' . $dirPathParts['filename'] . '.xml'; + if (!is_file($file)) + { + $file = $directory . '/langmetadata.xml'; + } + if (!is_file($file)) { continue;