Best Atoum code snippet using script.setLocale
config.php
Source:config.php
1<?php2// rcs_id('$Id: config.php 7797 2010-12-21 13:23:45Z vargenau $');3/*4 * NOTE: The settings here should probably not need to be changed.5 * The user-configurable settings have been moved to IniConfig.php6 * The run-time code has been moved to lib/IniConfig.php:fix_configs()7 */8if (!defined("LC_ALL")) {9 define("LC_ALL", 0);10 define("LC_CTYPE", 2);11}12// debug flags:13define ('_DEBUG_VERBOSE', 1); // verbose msgs and add validator links on footer14define ('_DEBUG_PAGELINKS', 2); // list the extraced pagelinks at the top of each pages15define ('_DEBUG_PARSER', 4); // verbose parsing steps16define ('_DEBUG_TRACE', 8); // test php memory usage, prints php debug backtraces17define ('_DEBUG_INFO', 16);18define ('_DEBUG_APD', 32); // APD tracing/profiling19define ('_DEBUG_LOGIN', 64); // verbose login debug-msg (settings and reason for failure)20define ('_DEBUG_SQL', 128); // force check db, force optimize, print some debugging logs21define ('_DEBUG_REMOTE', 256); // remote debug into subrequests (xmlrpc, ajax, wikiwyg, ...)22 // or test local SearchHighlight.23 // internal links have persistent ?start_debug=124function isCGI() {25 return (substr(php_sapi_name(),0,3) == 'cgi' and26 isset($GLOBALS['HTTP_ENV_VARS']['GATEWAY_INTERFACE']) and27 @preg_match('/CGI/',$GLOBALS['HTTP_ENV_VARS']['GATEWAY_INTERFACE']));28}29// essential internal stuff30if (!check_php_version(5,3)) {31 set_magic_quotes_runtime(0);32}33/**34 * Browser Detection Functions35 *36 * @author: ReiniUrban37 */38function browserAgent() {39 static $HTTP_USER_AGENT = false;40 if ($HTTP_USER_AGENT !== false) return $HTTP_USER_AGENT;41 if (!$HTTP_USER_AGENT)42 $HTTP_USER_AGENT = @$GLOBALS['HTTP_SERVER_VARS']['HTTP_USER_AGENT'];43 if (!$HTTP_USER_AGENT) // CGI44 $HTTP_USER_AGENT = @$GLOBALS['HTTP_ENV_VARS']['HTTP_USER_AGENT'];45 if (!$HTTP_USER_AGENT) // local CGI testing46 $HTTP_USER_AGENT = 'none';47 return $HTTP_USER_AGENT;48}49function browserDetect($match) {50 return (strpos(strtolower(browserAgent()), strtolower($match)) !== false);51}52// returns a similar number for Netscape/Mozilla (gecko=5.0)/IE/Opera features.53function browserVersion() {54 $agent = browserAgent();55 if (strstr($agent, "Mozilla/4.0 (compatible; MSIE"))56 return (float)substr($agent, 30);57 elseif (strstr($agent, "Mozilla/5.0 (compatible; Konqueror/"))58 return (float)substr($agent, 36);59 elseif (strstr($agent, "AppleWebKit/"))60 return (float)substr($agent, strpos($agent, "AppleWebKit/") + 12);61 else62 return (float)substr($agent, 8);63}64function isBrowserIE() {65 return (browserDetect('Mozilla/') and66 browserDetect('MSIE'));67}68// must omit display alternate stylesheets: konqueror 3.1.469// http://sourceforge.net/tracker/index.php?func=detail&aid=945154&group_id=6121&atid=10612170function isBrowserKonqueror($version = false) {71 if ($version) return browserDetect('Konqueror/') and browserVersion() >= $version;72 return browserDetect('Konqueror/');73}74// MacOSX Safari has certain limitations. Need detection and patches.75// * no <object>, only <embed>76function isBrowserSafari($version = false) {77 $found = browserDetect('Spoofer/');78 $found = browserDetect('AppleWebKit/') or $found;79 if ($version) return $found and browserVersion() >= $version;80 return $found;81}82function isBrowserOpera($version = false) {83 if ($version) return browserDetect('Opera/') and browserVersion() >= $version;84 return browserDetect('Opera/');85}86/**87 * If $LANG is undefined:88 * Smart client language detection, based on our supported languages89 * HTTP_ACCEPT_LANGUAGE="de-at,en;q=0.5"90 * => "de"91 * We should really check additionally if the i18n HomePage version is defined.92 * So must defer this to the request loop.93 */94function guessing_lang ($languages=false) {95 if (!$languages) {96 // make this faster97 $languages = array("en","de","es","fr","it","ja","zh","nl","sv");98 }99 $accept = false;100 if (isset($GLOBALS['request'])) // in fixup-dynamic-config there's no request yet101 $accept = $GLOBALS['request']->get('HTTP_ACCEPT_LANGUAGE');102 elseif (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE']))103 $accept = $_SERVER['HTTP_ACCEPT_LANGUAGE'];104 if ($accept) {105 $lang_list = array();106 $list = explode(",", $accept);107 for ($i=0; $i<count($list); $i++) {108 $pos = strchr($list[$i], ";") ;109 if ($pos === false) {110 // No Q it is only a locale...111 $lang_list[$list[$i]] = 100;112 } else {113 // Has a Q rating114 $q = explode(";",$list[$i]) ;115 $loc = $q[0] ;116 $q = explode("=",$q[1]) ;117 $lang_list[$loc] = $q[1]*100 ;118 }119 }120 // sort by q desc121 arsort($lang_list);122 // compare with languages, ignoring sublang and charset123 foreach ($lang_list as $lang => $q) {124 if (in_array($lang, $languages))125 return $lang;126 // de_DE.iso8859-1@euro => de_DE.iso8859-1, de_DE, de127 // de-DE => de-DE, de128 foreach (array('@', '.', '_') as $sep) {129 if ( ($tail = strchr($lang, $sep)) ) {130 $lang_short = substr($lang, 0, -strlen($tail));131 if (in_array($lang_short, $languages))132 return $lang_short;133 }134 }135 if ($pos = strchr($lang, "-") and in_array(substr($lang, 0, $pos), $languages))136 return substr($lang, 0, $pos);137 }138 }139 return $languages[0];140}141/**142 * Smart setlocale().143 *144 * This is a version of the builtin setlocale() which is145 * smart enough to try some alternatives...146 *147 * @param mixed $category148 * @param string $locale149 * @return string The new locale, or <code>false</code> if unable150 * to set the requested locale.151 * @see setlocale152 * [56ms]153 */154function guessing_setlocale ($category, $locale) {155 $alt = array('en' => array('C', 'en_US', 'en_GB', 'en_AU', 'en_CA', 'english'),156 'de' => array('de_DE', 'de_DE', 'de_DE@euro',157 'de_AT@euro', 'de_AT', 'German_Austria.1252', 'deutsch',158 'german', 'ge'),159 'es' => array('es_ES', 'es_MX', 'es_AR', 'spanish'),160 'nl' => array('nl_NL', 'dutch'),161 'fr' => array('fr_FR', 'français', 'french'),162 'it' => array('it_IT'),163 'sv' => array('sv_SE'),164 'ja.utf-8' => array('ja_JP','ja_JP.utf-8','japanese'),165 'ja.euc-jp' => array('ja_JP','ja_JP.eucJP','japanese.euc'),166 'zh' => array('zh_TW', 'zh_CN'),167 );168 if (!$locale or $locale=='C') {169 // do the reverse: return the detected locale collapsed to our LANG170 $locale = setlocale($category, '');171 if ($locale) {172 if (strstr($locale, '_')) list ($lang) = explode('_', $locale);173 else $lang = $locale;174 if (strlen($lang) > 2) {175 foreach ($alt as $try => $locs) {176 if (in_array($locale, $locs) or in_array($lang, $locs)) {177 //if (empty($GLOBALS['LANG'])) $GLOBALS['LANG'] = $try;178 return $try;179 }180 }181 }182 }183 }184 if (strlen($locale) == 2)185 $lang = $locale;186 else187 list ($lang) = explode('_', $locale);188 if (!isset($alt[$lang]))189 return false;190 foreach ($alt[$lang] as $try) {191 if ($res = setlocale($category, $try))192 return $res;193 // Try with charset appended...194 $try = $try . '.' . $GLOBALS['charset'];195 if ($res = setlocale($category, $try))196 return $res;197 foreach (array(".", '@', '_') as $sep) {198 if ($i = strpos($try, $sep)) {199 $try = substr($try, 0, $i);200 if (($res = setlocale($category, $try)))201 return $res;202 }203 }204 }205 return false;206 // A standard locale name is typically of the form207 // language[_territory][.codeset][@modifier], where language is208 // an ISO 639 language code, territory is an ISO 3166 country code,209 // and codeset is a character set or encoding identifier like210 // ISO-8859-1 or UTF-8.211}212// [99ms]213function update_locale($loc) {214 if ($loc == 'C' or $loc == 'en') return;215 // $LANG or DEFAULT_LANGUAGE is too less information, at least on unix for216 // setlocale(), for bindtextdomain() to succeed.217 $setlocale = guessing_setlocale(LC_ALL, $loc); // [56ms]218 if (!$setlocale) { // system has no locale for this language, so gettext might fail219 $setlocale = FileFinder::_get_lang();220 list ($setlocale,) = explode('_', $setlocale, 2);221 $setlocale = guessing_setlocale(LC_ALL, $setlocale); // try again222 if (!$setlocale) $setlocale = $loc;223 }224 // Try to put new locale into environment (so any225 // programs we run will get the right locale.)226 if (!function_exists('bindtextdomain')) {227 // Reinitialize translation array.228 global $locale;229 $locale = array();230 // do reinit to purge PHP's static cache [43ms]231 if ( ($lcfile = FindLocalizedFile("LC_MESSAGES/phpwiki.php", 'missing_ok', 'reinit')) ) {232 include($lcfile);233 }234 } else {235 // If PHP is in safe mode, this is not allowed,236 // so hide errors...237 @putenv("LC_ALL=$setlocale");238 @putenv("LANG=$loc");239 @putenv("LANGUAGE=$loc");240 }241 // To get the POSIX character classes in the PCRE's (e.g.242 // [[:upper:]]) to match extended characters (e.g. GrüÃGott), we have243 // to set the locale, using setlocale().244 //245 // The problem is which locale to set? We would like to recognize all246 // upper-case characters in the iso-8859-1 character set as upper-case247 // characters --- not just the ones which are in the current $LANG.248 //249 // As it turns out, at least on my system (Linux/glibc-2.2) as long as250 // you setlocale() to anything but "C" it works fine. (I'm not sure251 // whether this is how it's supposed to be, or whether this is a bug252 // in the libc...)253 //254 // We don't currently use the locale setting for anything else, so for255 // now, just set the locale to US English.256 //257 // FIXME: Not all environments may support en_US? We should probably258 // have a list of locales to try.259 if (setlocale(LC_CTYPE, 0) == 'C') {260 $x = setlocale(LC_CTYPE, 'en_US.' . $GLOBALS['charset']);261 } else {262 $x = setlocale(LC_CTYPE, $setlocale);263 }264 return $loc;265}266function deduce_script_name() {267 $s = &$GLOBALS['HTTP_SERVER_VARS'];268 $script = @$s['SCRIPT_NAME'];269 if (empty($script) or $script[0] != '/') {270 // Some places (e.g. Lycos) only supply a relative name in271 // SCRIPT_NAME, but give what we really want in SCRIPT_URL.272 if (!empty($s['SCRIPT_URL']))273 $script = $s['SCRIPT_URL'];274 }275 return $script;276}277function IsProbablyRedirectToIndex () {278 // This might be a redirect to the DirectoryIndex,279 // e.g. REQUEST_URI = /dir/?some_action got redirected280 // to SCRIPT_NAME = /dir/index.php281 // In this case, the proper virtual path is still282 // $SCRIPT_NAME, since pages appear at283 // e.g. /dir/index.php/HomePage.284 $requri = preg_replace('/\?.*$/','',$GLOBALS['HTTP_SERVER_VARS']['REQUEST_URI']);285 $requri = preg_quote($requri, '%');286 return preg_match("%^${requri}[^/]*$%", $GLOBALS['HTTP_SERVER_VARS']['SCRIPT_NAME']);287}288// needed < php5289// by bradhuizenga at softhome dot net from the php docs290if (!function_exists('str_ireplace')) {291 function str_ireplace($find, $replace, $string) {292 if (!is_array($find)) $find = array($find);293 if (!is_array($replace)) {294 if (!is_array($find))295 $replace = array($replace);296 else {297 // this will duplicate the string into an array the size of $find298 $c = count($find);299 $rString = $replace;300 unset($replace);301 for ($i = 0; $i < $c; $i++) {302 $replace[$i] = $rString;303 }304 }305 }306 foreach ($find as $fKey => $fItem) {307 $between = explode(strtolower($fItem),strtolower($string));308 $pos = 0;309 foreach ($between as $bKey => $bItem) {310 $between[$bKey] = substr($string,$pos,strlen($bItem));311 $pos += strlen($bItem) + strlen($fItem);312 }313 $string = implode($replace[$fKey], $between);314 }315 return($string);316 }317}318// htmlspecialchars_decode exists for PHP >= 5.1319if (!function_exists('htmlspecialchars_decode')) {320 function htmlspecialchars_decode($text) {321 return strtr($text, array_flip(get_html_translation_table(HTML_SPECIALCHARS)));322 }323}324/**325 * safe php4 definition for clone.326 * php5 copies objects by reference, but we need to clone "deep copy" in some places.327 * (BlockParser)328 * We need to eval it as workaround for the php5 parser.329 * See http://www.acko.net/node/54330 */331if (!check_php_version(5)) {332 eval('333 function clone($object) {334 return $object;335 }336 ');337}338function getUploadFilePath() {339 if (defined('UPLOAD_FILE_PATH')) {340 // Force creation of the returned directory if it does not exist.341 if (!file_exists(UPLOAD_FILE_PATH)) {342 mkdir(UPLOAD_FILE_PATH, 0775);343 }344 if (string_ends_with(UPLOAD_FILE_PATH, "/")345 or string_ends_with(UPLOAD_FILE_PATH, "\\")) {346 return UPLOAD_FILE_PATH;347 } else {348 return UPLOAD_FILE_PATH."/";349 }350 }351 return defined('PHPWIKI_DIR')352 ? PHPWIKI_DIR . "/uploads/"353 : realpath(dirname(__FILE__) . "/../uploads/");354}355function getUploadDataPath() {356 if (defined('UPLOAD_DATA_PATH')) {357 return string_ends_with(UPLOAD_DATA_PATH, "/")358 ? UPLOAD_DATA_PATH : UPLOAD_DATA_PATH."/";359 }360 return SERVER_URL . (string_ends_with(DATA_PATH, "/") ? '' : "/")361 . DATA_PATH . '/uploads/';362}363// Local Variables:364// mode: php365// tab-width: 8366// c-basic-offset: 4367// c-hanging-comment-ender-p: nil368// indent-tabs-mode: nil369// End:370?>...
navbar.php
Source:navbar.php
...10 <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">11 <img src="<?php echo getLocaleFlag(); ?>"> <?php echo localize("Wiki.Global.Language-Name"); ?>12 </a>13 <div class="dropdown-menu dropdown-menu-right p-1" style="min-width: 7.5rem" aria-labelledby="navbarDropdown">14 <a class="dropdown-item p-1" onclick="setLocale('en-GB')"><img class="flag-gb" src="https://static.plajer.xyz/img/flag_placeholder_invisible.png"> English</a>15 <a class="dropdown-item p-1" onclick="setLocale('cs-CZ')"><img class="flag-cs" src="https://static.plajer.xyz/img/flag_placeholder_invisible.png"> ÄeÅ¡tina</a>16 <a class="dropdown-item p-1" onclick="setLocale('de-DE')"><img class="flag-de" src="https://static.plajer.xyz/img/flag_placeholder_invisible.png"> Deutsch</a>17 <a class="dropdown-item p-1" onclick="setLocale('es-ES')"><img class="flag-es" src="https://static.plajer.xyz/img/flag_placeholder_invisible.png"> Español</a>18 <a class="dropdown-item p-1" onclick="setLocale('fr-FR')"><img class="flag-fr" src="https://static.plajer.xyz/img/flag_placeholder_invisible.png"> Français</a>19 <a class="dropdown-item p-1" onclick="setLocale('hu-HU')"><img class="flag-hu" src="https://static.plajer.xyz/img/flag_placeholder_invisible.png"> Magyar</a>20 <a class="dropdown-item p-1" onclick="setLocale('nl-NL')"><img class="flag-nl" src="https://static.plajer.xyz/img/flag_placeholder_invisible.png"> Nederlands</a>21 <a class="dropdown-item p-1" onclick="setLocale('pl-PL')"><img class="flag-pl" src="https://static.plajer.xyz/img/flag_placeholder_invisible.png"> Polski</a>22 <a class="dropdown-item p-1" onclick="setLocale('ro-RO')"><img class="flag-ro" src="https://static.plajer.xyz/img/flag_placeholder_invisible.png"> RomânÄ</a>23 <a class="dropdown-item p-1" onclick="setLocale('ru-RU')"><img class="flag-ru" src="https://static.plajer.xyz/img/flag_placeholder_invisible.png"> PÑÑÑкий</a>24 <a class="dropdown-item p-1" onclick="setLocale('th-TH')"><img class="flag-th" src="https://static.plajer.xyz/img/flag_placeholder_invisible.png"> ภาษาà¹à¸à¸¢</a>25 <a class="dropdown-item p-1" onclick="setLocale('zh-CN')"><img class="flag-cn" src="https://static.plajer.xyz/img/flag_placeholder_invisible.png"> ç®ä½ä¸æ</a>26 <a class="dropdown-item p-1" onclick="setLocale('zh-TW')"><img class="flag-tw" src="https://static.plajer.xyz/img/flag_placeholder_invisible.png"> ç¹é«ä¸æ</a>27 </div>28 </li>29 </ul>30 </div>31</nav>32<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>33<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>34<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>35<script>36 function setLocale(locale) {37 let date = new Date();38 date.setTime(date.getTime() + 30 * 6 * 24 * 60 * 60 * 1000 /* 6 months */);39 document.cookie = "preferred_locale=" + locale + "; expires=" + date.toUTCString() + ";path=/;domain=.plajer.xyz";40 window.location.reload(false);41 }...
setLocale
Using AI Code Generation
1$script->setLocale('en_US');2$script->getLocale();3$script->setScript('Latn');4$script->getScript();5$script->setNumberingSystem('latn');6$script->getNumberingSystem();7$script->getNumberingSystems();8$script->setLanguage('en');9$script->getLanguage();10$script->getLanguages();11$script->getLocaleDisplayScript('en_US');12$script->getLocaleDisplayLanguage('en_US');13$script->getLocaleDisplayCountry('en_US');14$script->getLocaleDisplayVariant('en_US');15$script->getLocaleDisplayName('en_US');16$script->getDisplayScript('en_US');17$script->getDisplayLanguage('en_US');18$script->getDisplayCountry('en_US');19$script->getDisplayVariant('en_US');20$script->getDisplayName('en_US');21$script->getDisplayNames();22$script->getDisplayScript('en_US');23$script->getDisplayLanguage('en_US');24$script->getDisplayCountry('en_US');25$script->getDisplayVariant('en
setLocale
Using AI Code Generation
1$script = new script;2$script->setLocale('en_US');3$script->getScript();4$script = new script;5$script->setLocale('es_ES');6$script->getScript();7$script = new script;8$script->setLocale('fr_FR');9$script->getScript();10$script = new script;11$script->setLocale('de_DE');12$script->getScript();13$script = new script;14$script->setLocale('it_IT');15$script->getScript();16$script = new script;17$script->setLocale('pt_PT');18$script->getScript();19$script = new script;20$script->setLocale('ja_JP');21$script->getScript();22$script = new script;23$script->setLocale('ko_KR');24$script->getScript();25$script = new script;26$script->setLocale('zh_CN');27$script->getScript();28$script = new script;29$script->setLocale('zh_TW');30$script->getScript();31$script = new script;32$script->setLocale('en_US');33$script->getScript();34$script = new script;35$script->setLocale('es_ES');36$script->getScript();37$script = new script;38$script->setLocale('fr_FR');39$script->getScript();
setLocale
Using AI Code Generation
1$script->setLocale('en_US');2$script->setTimeZone('America/Los_Angeles');3$script->setTimeZoneOffset(5.5);4$script->setTimeZoneOffsetFromGMT(5.5);5$script->setTimeZoneId('America/Los_Angeles');6$script->setTimeZoneName('Pacific Standard Time');7$script->setTimeZoneAbbreviation('PST');8$script->setTimeZoneDst(1);9$script->setTimeZoneDstStart(1);10$script->setTimeZoneDstEnd(1);11$script->setTimeZoneOffsetDst(1);12$script->setTimeZoneOffsetDstFromGMT(1);13$script->setTimeZoneOffsetDstFromGMT(1);14$script->setTimeZoneOffsetDstFromGMT(1);
setLocale
Using AI Code Generation
1setlocale(LC_ALL, "en_US.UTF-8");2echo "Locale for this script is: ". setlocale(LC_ALL, 0)."\n";3setlocale(LC_ALL, "en_US");4echo "Locale for this script is: ". setlocale(LC_ALL, 0)."\n";5setlocale(LC_ALL, "en_US.UTF-8");6echo "Locale for this script is: ". setlocale(LC_ALL, 0)."\n";7setlocale(LC_ALL, "en_US");8echo "Locale for this script is: ". setlocale(LC_ALL, 0)."\n";9setlocale(LC_ALL, "en_US.UTF-8");10echo "Locale for this script is: ". setlocale(LC_ALL, 0)."\n";11setlocale(LC_ALL, "en_US");12echo "Locale for this script is: ". setlocale(LC_ALL, 0)."\n";13setlocale(LC_ALL, "en_US.UTF-8");14echo "Locale for this script is: ". setlocale(LC_ALL, 0)."\n";15setlocale(LC_ALL, "en_US");
setLocale
Using AI Code Generation
1var_dump(Script::setLocale(LC_ALL, "de_DE", SORT_NUMERIC));2var_dump(Script::setLocale(LC_ALL, "en_US", SORT_NUMERIC));3var_dump(Script::setLocale(LC_ALL, "fr_FR", SORT_NUMERIC));4var_dump(Script::setLocale(LC_ALL, "de_DE", SORT_NUMERIC));5var_dump(Script::setLocale(LC_ALL, "en_US", SORT_NUMERIC));6var_dump(Script::setLocale(LC_ALL, "fr_FR", SORT_NUMERIC));7var_dump(Script::setLocale(LC_ALL, "de_DE", SORT_NUMERIC));8var_dump(Script::setLocale(LC_ALL, "en_US", SORT_NUMERIC));9var_dump(Script::setLocale(LC_ALL, "fr_FR", SORT_NUMERIC));10var_dump(Script::setLocale(LC_ALL, "de_DE", SORT_NUMERIC));11var_dump(Script::setLocale(LC_ALL, "en_US", SORT_NUMERIC));
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Execute automation tests with setLocale on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.
Test now for FreeGet 100 minutes of automation test minutes FREE!!