diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-02-23 18:03:33 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-02-23 18:03:33 +0000 |
commit | f27637b07c4f148ff732f4dfffa7ec3e95c85e27 (patch) | |
tree | 4221c002cd119004d5895c119b66d4a23ab4c1d1 /lib/tasks | |
parent | ce84bb1a0194d98b4db99e258cc0ada6b98e19b8 (diff) | |
download | redmine-f27637b07c4f148ff732f4dfffa7ec3e95c85e27.tar.gz redmine-f27637b07c4f148ff732f4dfffa7ec3e95c85e27.zip |
Adds tasks for locales maintenance.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4937 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/tasks')
-rw-r--r-- | lib/tasks/locales.rake | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/tasks/locales.rake b/lib/tasks/locales.rake index 512538475..7b8efd470 100644 --- a/lib/tasks/locales.rake +++ b/lib/tasks/locales.rake @@ -1,3 +1,10 @@ +desc 'Updates and checks locales against en.yml' +task :locales do + %w(locales:update locales:check_interpolation).collect do |task| + Rake::Task[task].invoke + end +end + namespace :locales do desc 'Updates language files based on en.yml content (only works for new top level keys).' task :update do @@ -28,6 +35,26 @@ namespace :locales do lang.close end end + + desc 'Checks interpolation arguments in locals against en.yml' + task :check_interpolation do + dir = ENV['DIR'] || './config/locales' + en_strings = YAML.load(File.read(File.join(dir,'en.yml')))['en'] + files = Dir.glob(File.join(dir,'*.{yaml,yml}')) + files.each do |file| + file_strings = YAML.load(File.read(file)) + file_strings = file_strings[file_strings.keys.first] + + file_strings.each do |key, string| + next unless string.is_a?(String) + string.scan /%\{\w+\}/ do |match| + unless en_strings[key].nil? || en_strings[key].include?(match) + puts "#{file}: #{key} uses #{match} not found in en.yml" + end + end + end + end + end desc <<-END_DESC Removes a translation string from all locale file (only works for top-level childless non-multiline keys, probably doesn\'t work on windows). |