/** * Returns language code for given language name * * @static * @public * @param string $name language name * @return string language code */ function Name2Code($name) { $codes = JoomlaTuneLanguageTools::getLanguageCodes(); foreach ($codes as $code => $meta) { if ($meta[0] == strtolower($name)) { return $code; } } return ''; }
public static function convertLanguages10() { global $mainframe; $joomlaLanguagesPath = $mainframe->getCfg('absolute_path') . '/language'; $componentPath = $mainframe->getCfg('absolute_path') . '/components/com_jcomments'; require_once $componentPath . '/libraries/convert/utf8.class.php'; require_once $componentPath . '/libraries/joomlatune/filesystem.php'; require_once $componentPath . '/libraries/joomlatune/language.tools.php'; $codeMap = JoomlaTuneLanguageTools::getLanguageCodes(); $joomlaLanguageFiles = JoomlaTuneFS::readDirectory($joomlaLanguagesPath, '[a-z]+\\.xml', false, false); $joomlaLanguages = array(); foreach ($joomlaLanguageFiles as $file) { $joomlaLanguages[] = str_replace('.xml', '', $file); } $path = $componentPath . '/languages'; $filter = '[a-z]{2}-[A-Z]{2}\\.com_jcomments\\.ini'; $files = JoomlaTuneFS::readDirectory($path, $filter, false, true); $files2 = JoomlaTuneFS::readDirectory($path . '/administrator', $filter, false, true); $files = array_merge($files, $files2); foreach ($files as $file) { $m = array(); preg_match('#([a-z]{2}-[A-Z]{2})#', (string) $file, $m); $code = $m[0]; $language = isset($codeMap[$code]) ? $codeMap[$code][0] : ''; $charset = isset($codeMap[$code]) ? $codeMap[$code][1] : 'iso-8859-1'; if ($language != '' && in_array($language, $joomlaLanguages)) { if (defined('_ISO2')) { $charset = strtolower(_ISO2); if ($charset == 'utf-8' || $charset == 'utf8') { $newFile = str_replace($code . '.com_jcomments.ini', $language . '.ini', $file); @copy((string) $file, $newFile); } else { JCommentsInstallerLanguageHelper::_convertFile10($file, $code, $charset, $language); } } else { JCommentsInstallerLanguageHelper::_convertFile10($file, $code, $charset, $language); } } } unset($codeMap); }