function get_locale_information($locale_string) { $info = null; if (preg_match('/^' . locale::local_regexp() . '/', $locale_string, $regs)) { $info = array(); $language = strtolower($regs[1]); $country = ''; if (isset($regs[3])) { $country = strtoupper($regs[3]); } $charset = ''; if (isset($regs[5])) { $charset = strtolower($regs[5]); } $country_variation = ''; if (isset($regs[7])) { $country_variation = strtolower($regs[7]); } $locale = $language; if ($country !== '') { $locale .= '-' . $country; } $info['language'] = $language; $info['country'] = $country; $info['country-variation'] = $country_variation; $info['charset'] = $charset; $info['locale'] = $locale; } else { $info = array(); $locale = strtolower($locale_string); $language = $locale; $info['language'] = $language; $info['country'] = ''; $info['country-variation'] = ''; $info['charset'] = ''; $info['locale'] = $locale; } return $info; }