##// END OF EJS Templates
Adds tasks for locales maintenance....
Jean-Philippe Lang -
r4817:f27637b07c4f
parent child
Show More
@@ -1,3 +1,10
1 desc 'Updates and checks locales against en.yml'
2 task :locales do
3 %w(locales:update locales:check_interpolation).collect do |task|
4 Rake::Task[task].invoke
5 end
6 end
7
1 namespace :locales do
8 namespace :locales do
2 desc 'Updates language files based on en.yml content (only works for new top level keys).'
9 desc 'Updates language files based on en.yml content (only works for new top level keys).'
3 task :update do
10 task :update do
@@ -28,6 +35,26 namespace :locales do
28 lang.close
35 lang.close
29 end
36 end
30 end
37 end
38
39 desc 'Checks interpolation arguments in locals against en.yml'
40 task :check_interpolation do
41 dir = ENV['DIR'] || './config/locales'
42 en_strings = YAML.load(File.read(File.join(dir,'en.yml')))['en']
43 files = Dir.glob(File.join(dir,'*.{yaml,yml}'))
44 files.each do |file|
45 file_strings = YAML.load(File.read(file))
46 file_strings = file_strings[file_strings.keys.first]
47
48 file_strings.each do |key, string|
49 next unless string.is_a?(String)
50 string.scan /%\{\w+\}/ do |match|
51 unless en_strings[key].nil? || en_strings[key].include?(match)
52 puts "#{file}: #{key} uses #{match} not found in en.yml"
53 end
54 end
55 end
56 end
57 end
31
58
32 desc <<-END_DESC
59 desc <<-END_DESC
33 Removes a translation string from all locale file (only works for top-level childless non-multiline keys, probably doesn\'t work on windows).
60 Removes a translation string from all locale file (only works for top-level childless non-multiline keys, probably doesn\'t work on windows).
General Comments 0
You need to be logged in to leave comments. Login now