BB_RunPluginAction("bb_main_edit_page_opt_ping_translation_options"); BB_PropertyForm($options); BB_RunPluginAction("post_bb_main_edit_page_opt_ping_translation"); } else { if ($_REQUEST["bb_action"] == "bb_main_edit_page_opt_create_translation_submit") { BB_RunPluginAction("pre_bb_main_edit_page_opt_create_translation_submit"); $lang = BB_GetCleanLang($_REQUEST["lang2"] != "" ? $_REQUEST["lang2"] : ($lang = $_REQUEST["otherlang"])); $desc = BB_GetIANADesc($lang, false); if ($desc === false) { BB_PropertyFormError("Invalid language code specified."); } $lang = str_replace("-", "_", $lang); if (isset($bb_page["langs"][$lang])) { BB_PropertyFormError("Translation already exists."); } $langmap = str_replace("-", "_", BB_GetCleanLang($_REQUEST["langmap"])); if ($langmap != "" && (!isset($bb_page["langs"][$langmap]) || is_string($bb_page["langs"][$langmap]))) { BB_PropertyFormError("Unable to create translation mapping."); } if (!BB_CreateLangPage($lang, $langmap)) { BB_PropertyFormError("Unable to create translation."); } // Map root ('en') to translation ('en_us'). $Pos = strpos($lang, "_"); if ($Pos !== false) { $langmap2 = $lang; $lang2 = substr($lang, 0, $Pos); BB_CreateLangPage($lang2, $langmap2); } if ($langmap == "" && $_REQUEST["notify"] == "yes") { require_once "translate.php";
function BB_GetIANAInfo($lang, $usecache = true) { global $bb_iana_lang_desc_cache, $bb_common_lang, $bb_iana_lang, $bb_paths; $lang = BB_GetCleanLang($lang); if ($usecache) { if (!file_exists((isset($bb_paths) ? $bb_paths["ROOT_PATH"] : ROOT_PATH) . "/iana_lang_desc_cache.php")) { $bb_iana_lang_desc_cache = array(); } else { require_once (isset($bb_paths) ? $bb_paths["ROOT_PATH"] : ROOT_PATH) . "/iana_lang_desc_cache.php"; if (isset($bb_iana_lang_desc_cache[$lang])) { return $bb_iana_lang_desc_cache[$lang]; } } } $supportpath = isset($bb_paths) ? $bb_paths["ROOT_PATH"] . "/" . $bb_paths["SUPPORT_PATH"] : ROOT_PATH . "/" . SUPPORT_PATH; if (file_exists($supportpath . "/php/common_lang.php")) { require_once $supportpath . "/php/common_lang.php"; if (isset($bb_common_lang[$lang])) { return BB_AddIANACache($lang, $bb_common_lang[$lang], $usecache); } } require_once $supportpath . "/php/iana_lang.php"; $mappath = array($lang); while (isset($bb_iana_lang["grandfathered"][$lang])) { if (!isset($bb_iana_lang["grandfathered"][$lang]["pv"])) { return BB_AddIANACache($lang, array(array($bb_iana_lang["grandfathered"][$lang]["ds"]), $mappath), $usecache); } $lang2 = $bb_iana_lang["grandfathered"][$lang]["pv"]; if ($lang == $lang2) { return "[Infinite loop detected]"; } $lang = $lang2; $mappath[] = $lang; } $scanpath = array("language", "extlang", "script", "region", "variant", "extension", "privateuse"); do { $reset = false; $lang = explode("-", $lang); $descpath = array(); $y = 0; for ($x = 0; $x < count($scanpath) && $y < count($lang); $x++) { if (isset($bb_iana_lang[$scanpath[$x]]) && isset($bb_iana_lang[$scanpath[$x]][strtolower($lang[$y])])) { $info = $bb_iana_lang[$scanpath[$x]][strtolower($lang[$y])]; if (isset($info["pv"])) { $lang2 = $info["pv"]; if ($lang == $lang2) { return "[Infinite loop detected]"; } $lang = $lang2; $mappath[] = $lang; $reset = true; break; } $descpath[] = $info["ds"]; $y++; } } } while ($reset); return BB_AddIANACache($mappath[0], array($descpath, $mappath), $usecache); }