Class: Locale::Object
- Inherits:
-
Object
- Object
- Locale::Object
- Defined in:
- lib/locale_selector.rb
Overview
Patch for the gettext gem 1.92 and earlier. Now incorporated into gettext.
Class Method Summary collapse
-
.parse(locale_name) ⇒ Object
:nodoc:.
Class Method Details
.parse(locale_name) ⇒ Object
:nodoc:
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/locale_selector.rb', line 236 def self.parse(locale_name) # :nodoc: # PATCH: the following line is new locale_name = "en" if locale_name.nil? || locale_name.empty? 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[A-Z][a-z]+\Z/ #Latn => script tmp = script script = country if tmp =~ /\A[A-Z]+\Z/ #US => country country = tmp else country = nil variant = tmp end else country = country.upcase if script !~ /\A[A-Z][a-z]+\Z/ #Latn => script variant = script script = nil end end end [language, country, charset, script, variant, modifier] end |