Class: Baykit::BayServer::Util::Locale

Inherits:
Object
  • Object
show all
Defined in:
lib/baykit/bayserver/util/locale.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(language, country) ⇒ Locale

Returns a new instance of Locale.



8
9
10
11
# File 'lib/baykit/bayserver/util/locale.rb', line 8

def initialize(language, country)
  @language = language
  @country = country
end

Instance Attribute Details

#countryObject (readonly)

Returns the value of attribute country.



6
7
8
# File 'lib/baykit/bayserver/util/locale.rb', line 6

def country
  @country
end

#languageObject (readonly)

Returns the value of attribute language.



5
6
7
# File 'lib/baykit/bayserver/util/locale.rb', line 5

def language
  @language
end

Class Method Details

.defaultObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/baykit/bayserver/util/locale.rb', line 14

def self.default()
  lang = ENV['LANG']
  if StringUtil.set?(lang)
    begin
      language = lang[0, 2]
      country = lang[3, 2]
      return Locale.new(language, country)
    rescue => e
      BayLog.error_e(e)
    end
  end
  return Locale.new("en", "US")
end