mozo-user connection changes

This commit is contained in:
2015-09-06 17:29:34 +02:00
parent c55740be0a
commit 4ef7ecba41
13 changed files with 379 additions and 319 deletions
+42
View File
@@ -0,0 +1,42 @@
#!/usr/bin/env ruby
#require 'pathname'
#require 'active_support/all'
#require 'yaml'
#require 'pry'
#$root = Pathname.new File.expand_path('../../', __FILE__)
class UserApp
def path
Pathname.new File.expand_path('../../../mozo-user', __FILE__)
end
def user_translations
Dir.glob(Rails.root.join('config/user_locales/**/*.yml')).each_with_object({}) do |user_yaml, obj|
obj.deep_merge! YAML.load_file(user_yaml)
end
end
def all_translations
user_translations.deep_merge general_translations
end
def general_translations
Rails.application.config.i18n.available_locales.each_with_object({}) do |locale, obj|
obj[locale.to_s] = {
models: I18n.t('activemodel.models', locale: locale),
attributes: I18n.t('activemodel.attributes', locale: locale),
helpers: I18n.t('helpers', locale: locale),
pagination: I18n.t('views.pagination', locale: locale),
errors: I18n.t('errors', locale: locale),
date: {day_name: Hash[Date::DAYNAMES.map(&:downcase).zip(I18n.t('date.day_names', locale: locale))]}
}
end.deep_stringify_keys
end
def write_translations
File.open path.join('vendor/i18n/translations.js'), 'w+' do |f|
f.puts "$translations = #{JSON.pretty_generate all_translations}"
end
end
end
UserApp.new.write_translations