Class: ReVIEW::I18n

Inherits:
Object show all
Defined in:
lib/review/i18n.rb

Class Method Summary collapse

Class Method Details

.i18n(locale, user_i18n = {}) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/review/i18n.rb', line 13

def self.i18n(locale, user_i18n = {})
  locale ||= "ja"
  i18n_yaml_path = File.expand_path "i18n.yaml", File.dirname(__FILE__)
  @i18n = YAML.load_file(i18n_yaml_path)[locale]
  if @i18n
    @i18n.merge!(user_i18n)
  end
end

.setupObject



6
7
8
9
10
11
# File 'lib/review/i18n.rb', line 6

def self.setup
  user_i18n = YAML.load_file(File.expand_path "locale.yaml", ENV["PWD"])
  I18n.i18n user_i18n["locale"], user_i18n
rescue
  I18n.i18n "ja"
end

.t(str, args = nil) ⇒ Object



22
23
24
25
26
# File 'lib/review/i18n.rb', line 22

def self.t(str, args = nil)
  @i18n[str] % args
rescue
  str
end