Module: ChefApply::Text

Defined in:
lib/chef_apply/text.rb,
lib/chef_apply/text/text_wrapper.rb,
lib/chef_apply/text/error_translation.rb

Defined Under Namespace

Classes: ErrorTranslation, TextWrapper

Class Method Summary collapse

Class Method Details

._error_tableObject



26
27
28
29
30
31
32
# File 'lib/chef_apply/text.rb', line 26

def self._error_table
  # Though there may be several translations, en.yml will be the only one with
  # error metadata.
  path = File.join(_translation_path, "errors", "en.yml")
  raw_yaml = File.read(path)
  @error_table ||= YAML.load(raw_yaml, _translation_path, symbolize_names: true)[:errors]
end

._translation_pathObject



34
35
36
# File 'lib/chef_apply/text.rb', line 34

def self._translation_path
  @translation_path ||= File.join(File.dirname(__FILE__), "..", "..", "i18n")
end

.loadObject



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/chef_apply/text.rb', line 38

def self.load
  R18n.from_env(Text._translation_path)
  R18n.extension_places << File.join(Text._translation_path, "errors")
  t = R18n.get.t
  t.translation_keys.each do |k|
    k = k.to_sym
    define_singleton_method k do |*args|
      TextWrapper.new(t.send(k, *args))
    end
  end
end