class PolyglotCli::IO::Locale

Public Class Methods

path(locale_path, locale) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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| f.write(data.to_yaml(line_width: -1)) }
end