Class: BitClust::MessageCatalog

Inherits:
Object
  • Object
show all
Defined in:
lib/bitclust/messagecatalog.rb

Overview

Tiny implementation of message catalog (I18N) see data/bitclust/catalog/ja_JP.UTF-8

FIXME: support automatic encoding-conversion

Constant Summary collapse

ENCODING_MAP =
{
  'utf-8' => 'UTF-8',
  'euc-jp' => 'EUC-JP',
  'shift_jis' => 'Shift_JIS'
}

Instance Method Summary collapse

Constructor Details

#initialize(msgs, locale) ⇒ MessageCatalog

Returns a new instance of MessageCatalog.



84
85
86
87
# File 'lib/bitclust/messagecatalog.rb', line 84

def initialize(msgs, locale)
  @msgs = msgs
  @locale = locale
end

Instance Method Details

#inspectObject



89
90
91
# File 'lib/bitclust/messagecatalog.rb', line 89

def inspect
  "\#<#{self.class} #{@locale}>"
end

#translate(key, *args) ⇒ Object



93
94
95
96
# File 'lib/bitclust/messagecatalog.rb', line 93

def translate(key, *args)
  str = @msgs[key] || key
  sprintf(str, *args)
end