Sha256: bbc0ba545427dd2b83dfd4ef8b30efea38eee0e7edaed2df9a5eda0cdb705041
Contents?: true
Size: 1.42 KB
Versions: 28
Compression:
Stored size: 1.42 KB
Contents
# frozen_string_literal: true def create_translations %w[en fr].each do |local| locale_file = "config/locales/bo.#{local}.yml" unless File.exist?(locale_file) File.write(locale_file, { local => { 'bo' => { 'filters' => find_existing_translation('filters', local), 'record' => { 'created' => find_existing_translation('created', local), 'updated' => find_existing_translation('updated', local), 'destroyed' => find_existing_translation('destroyed', local) } } } }.to_yaml) end yaml_string = File.open locale_file data = YAML.load yaml_string data[local]['bo'][file_name.underscore.to_s] = { 'one' => find_existing_translation(bo_model.to_s.downcase, local), 'others' => find_existing_translation(bo_model.to_s.pluralize.downcase, local), 'subtitle' => find_existing_translation("list of #{bo_model.to_s.pluralize.downcase}", local), 'attributes' => model_attributes(local) } output = YAML.dump data File.write(locale_file, output) end end def model_attributes(local) hash = {} model_columns.each do |col| hash[col.to_s] = find_existing_translation(col, local) end hash end def find_existing_translation(col, local) return col.to_s.humanize.downcase if local == 'en' json = JSON.parse(File.read("#{__dir__}/files/#{local}.json")) json[col.to_s] end
Version data entries
28 entries across 28 versions & 1 rubygems