This commit is contained in:
amartynov 2015-09-22 15:01:32 +03:00
parent 684a48f6dd
commit 95c9da80b4

View File

@ -18,13 +18,13 @@ module Devops
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)