def self.parse(locale_name)
lang_charset, modifier = locale_name.split(/@/)
lang, charset = lang_charset.split(/\./)
language, country, script, variant = lang.gsub(/_/, "-").split('-')
language = language ? language.downcase : nil
language = "en" if language == "c" || language == "posix"
if country
if country =~ /[A-Z][a-z]+/
tmp = script
script = country
if tmp =~ /[A-Z]+/
country = tmp
else
country = nil
variant = tmp
end
else
country = country.upcase
if script !~ /[A-Z][a-z]+/
variant = script
script = nil
end
end
end
[language, country, charset, script, variant, modifier]
end