6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/localeapp/updater.rb', line 6
def update(data)
data['locales'].each do |short_code|
filename = File.join(Localeapp.configuration.translation_data_directory, "#{short_code}.yml")
if File.exist?(filename)
translations = Localeapp.load_yaml_file(filename)
if data['translations'] && data['translations'][short_code]
new_data = { short_code => data['translations'][short_code] }
translations = deep_merge translations, new_data
end
else
translations = { short_code => data['translations'][short_code] }
end
if data['deleted']
data['deleted'].each do |key|
remove_flattened_key!(translations, short_code, key)
end
end
if translations[short_code]
atomic_write(filename) do |file|
file.write generate_yaml(translations)
end
end
end
end
|