PHP- Get current locale -
i setting locale of website using function:
function set_locale($locale) { // ie. en, es $language = $locale; putenv("lang=".$language); setlocale(lc_all, $language); $domain = "phd"; bindtextdomain($domain, "locale"); bind_textdomain_codeset($domain, 'utf-8'); textdomain($domain); } // end set_locale when visits site, have ability change locale. trying somewhere else in site retrieve current locale is.
how this?
you can call setlocale so, , it'll return current local.
$currentlocal = setlocale(lc_all, 0); echo $currentlocal; //outputs c/en_us.utf-8/c/c/c/c on machine here documentation php.net commented @jrob
locale
if locale "0", locale setting not affected, current setting returned.
if locale null or empty string "", locale names set values of environment variables same names above categories, or "lang".
if locale array or followed additional parameters each array element or parameter tried set new locale until success. useful if locale known under different names on different systems or providing fallback possibly not available locale.
Comments
Post a Comment