13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/fifty/helpers/locales.rb', line 13
def self.compile
locales = Fifty.locales.map { |p| Dir[p] }.flatten
hash = {}
locales.each do |file|
name = File.basename(file, '.yml')
yaml = YAML.load(File.read(file))
hash.merge!(yaml)
end
Fifty.helper :t, "function(path) {
var current = locales[locale];
var elements = path.split('.');
while (elements.length > 0 ) {
current = current[elements.shift()];
}
return current;
}"
Fifty.shared :locale, "'#{I18n.locale.to_s}'"
Fifty.shared :locales, hash.to_json
end
|