function is_valid_code($code) { /* Check the given string is a valid language code. */ $lang = MLPLanguageHandler::compact_code($code); $short = $lang['short']; if (isset($short)) { return MLPLanguageHandler::is_valid_short_code($short); } return false; }
function _l10n_check_lang_code($lang) { if (!is_string($lang)) { echo 'Non-string language passed to _l10n_check_lang_code() ... ', var_dump($lang), br; return false; } if (empty($lang)) { echo 'Blank language passed to _l10n_check_lang_code()', br; return false; } if (strlen($lang) > 2) { $code = MLPLanguageHandler::compact_code($lang); if (isset($code['long'])) { $code = $code['long']; } else { $code = $code['short']; } } else { $code = $lang; } if (empty($code)) { echo 'Blank language code calculated in _l10n_check_lang_code()', br; return false; } if (!MLPLanguageHandler::is_valid_code($code)) { echo 'Invalid language code [' . $code . '] calculated in _l10n_check_lang_code()', br; return false; } return $code; }
function cleanup_7() { global $prefs; $langs = $this->pref('l10n-languages'); $this->add_report_item(gTxt('l10n-op_tables', array('{op}' => 'Drop', '{tables}' => 'per-language article')) . '…'); foreach ($langs as $lang) { $code = MLPLanguageHandler::compact_code($lang); $table_name = _l10n_make_textpattern_name($code); $sql = 'drop table `' . PFX . $table_name . '`'; $ok = @safe_query($sql); $this->add_report_item(gTxt('l10n-op_table', array('{op}' => 'Drop', '{table}' => MLPLanguageHandler::get_native_name_of_lang($lang) . ' [' . $table_name . ']')), $ok, true); } }
function l10n_rendition_lang($atts) { global $thisarticle, $rs; $r = ''; $lang = $thisarticle[L10N_COL_LANG] ? $thisarticle[L10N_COL_LANG] : @$rs[L10N_COL_LANG]; if (!$lang) { return $r; } $lang = MLPLanguageHandler::compact_code($lang); switch ($atts['length']) { case 'long': $r = $lang['long']; break; default: $r = $lang['short']; break; } return $r; }