Merge branch 'devops_3' of git.stu.neva.ru:cloudtechlab/devops-service into devops_3

This commit is contained in:
Anton Chuchkalov 2015-09-22 15:08:30 +03:00
commit 7e2d4bc875

View File

@ -15,16 +15,17 @@ module Devops
end end
def merge file def merge file
puts "Trying to merge messages with file '#{file}'"
lang = lang_key lang = lang_key
messages = read_file(file)[lang] messages = read_file(file)[lang]
raise "It is undefined main key '#{lang}' in file '#{file}'" if messages.nil? raise "It is undefined main key '#{lang}' in file '#{file}'" if messages.nil?
@@messages.merge!(messages) @@messages.deep_merge!(messages)
end end
def translate key, params={} def translate key, params={}
msg = @@messages msg = @@messages
key.split(".").each do |msgk| key.split(".").each do |msgk|
msg = msg[key] msg = msg[msgk]
raise "Invalid message key '#{key}'" if msg.nil? raise "Invalid message key '#{key}'" if msg.nil?
end end
raise "Invalid message value with key '#{key}', it must be a string" unless msg.is_a?(String) raise "Invalid message value with key '#{key}', it must be a string" unless msg.is_a?(String)