function _addLanguage($aLanguage, $aLangInfo) { $oDb = new BxDolModuleDb(); if (getLangIdByName($aLangInfo['Name'])) { // language already exists return false; } $sLangName = $oDb->escape($aLangInfo['Name']); $sLangFlag = $oDb->escape($aLangInfo['Flag']); $sLangTitle = $oDb->escape($aLangInfo['Title']); if (!$oDb->res("INSERT INTO `sys_localization_languages` VALUES (NULL, '{$sLangName}', '{$sLangFlag}', '{$sLangTitle}')")) { return false; } $iLangKey = $oDb->lastId(); foreach ($aLanguage as $sKey => $sValue) { $sDbKey = $oDb->escape($sKey); $sDbValue = $oDb->escape($sValue); $iExistedKey = $oDb->getOne("SELECT `ID` FROM `sys_localization_keys` WHERE `Key` = '{$sDbKey}'"); if (!$iExistedKey) { // key is missing, insert new key if (!$oDb->res("INSERT INTO `sys_localization_keys` VALUES (NULL, " . BX_DOL_LANGUAGE_CATEGORY_SYSTEM . ", '{$sDbKey}')")) { continue; } $iExistedKey = $oDb->lastId(); } $oDb->res("INSERT INTO `sys_localization_strings` VALUES({$iExistedKey}, {$iLangKey}, '{$sDbValue}')"); } return true; }