Permalink
Browse files

Move deep_merge! to R18n::Utils

  • Loading branch information...
1 parent 6996a3b commit 17caddc56dbaf2c8122ca1398dcb4d157f2552f4 @ai ai committed Nov 26, 2008
Showing with 17 additions and 13 deletions.
  1. +14 −0 lib/r18n-core.rb
  2. +3 −13 lib/r18n-core/translation.rb
View
@@ -41,4 +41,18 @@ def get
Thread.current['i18n']
end
end
+
+ module Utils
+ # Recursively hash merge
+ def self.deep_merge!(a, b)
+ b.each_pair do |name, value|
+ if Hash == a[name].class
+ self.deep_merge!(a[name], value)
+ else
+ a[name] = value
+ end
+ end
+ a
+ end
+ end
end
@@ -130,7 +130,9 @@ def self.load(locales, dirs)
translation = {}
dirs.each do |dir|
file = File.join(dir, "#{locale}.yml")
- self.deep_merge! translation, YAML::load_file(file) if File.exists? file
+ if File.exists? file
+ Utils.deep_merge! translation, YAML::load_file(file)
+ end
end
translations << translation
@@ -144,18 +146,6 @@ def self.load(locales, dirs)
self.new(locales, translations)
end
- # Recursively hash merge
- def self.deep_merge!(a, b)
- b.each_pair do |name, value|
- if Hash == a[name].class
- self.deep_merge!(a[name], value)
- else
- a[name] = value
- end
- end
- a
- end
-
# Is procedures in translations will be call. Set to false if user can
# upload or edit translations.
def self.call_proc=(call)

0 comments on commit 17caddc

Please sign in to comment.