Skip to content

Instantly share code, notes, and snippets.

@IceskYsl
Created June 14, 2010 18:00
Show Gist options
  • Save IceskYsl/438035 to your computer and use it in GitHub Desktop.
Save IceskYsl/438035 to your computer and use it in GitHub Desktop.
%w("en", "en_US", "_US", "en__POSIX", "en_US_POSIX", "zh-rCN" , "zh-r").each do |locale|
puts locale
if(locale =~ /^([^-_]+)[-_]?r?([^-_]+)?[-_]?([^-_]+?)$/)
puts "$1=#{$1},$2=#{$2},$3=#{$3}"
end
end
output
"en",
$1="en",$2=,$3=,
"en_US",
$1="en,$2=US",$3=,
"_US",
$1=",$2=US",$3=,
"en__POSIX",
$1="en,$2=,$3=POSIX",
"en_US_POSIX",
$1="en,$2=US,$3=POSIX",
"zh-rCN",
$1="zh,$2=CN",$3=,
"zh-r"
$1="zh,$2=,$3="
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment