Class: PolyglotCli::IO::Locale

Inherits:
Object
  • Object
show all
Extended by:
Helper::Terminal
Defined in:
lib/polyglot_cli/io/locale.rb

Class Method Summary collapse

Methods included from Helper::Terminal

prompt, success

Class Method Details

.path(locale_path, locale) ⇒ Object



17
18
19
# File 'lib/polyglot_cli/io/locale.rb', line 17

def path(locale_path, locale)
  "#{Dir.pwd}/#{locale_path}/#{locale}.yml"
end

.read(locale_path, locale) ⇒ Object



12
13
14
15
# File 'lib/polyglot_cli/io/locale.rb', line 12

def read(locale_path, locale)
  prompt.say("Reading translations from #{path(locale_path, locale)}")
  YAML.load_file(path(locale_path, locale))
end

.write(locale_path, data) ⇒ Object



7
8
9
10
# File 'lib/polyglot_cli/io/locale.rb', line 7

def write(locale_path, data)
  prompt.say("Writing translations to #{path(locale_path, data.keys[0])}")
  File.open(path(locale_path, data.keys[0]), 'w') { |f| YAML.dump(data, f) }
end