summaryrefslogtreecommitdiffstats
path: root/lib/tasks
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-05-10 11:41:30 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-05-10 11:41:30 +0000
commit2714f6bcacb3ccd11f9bede09f97f5817bb7310d (patch)
treee7e2e8eed4da143f9ff5b24954b9ebbc7c3344a4 /lib/tasks
parent0418774f501a3efe7583dbc7ba8dcae19928629d (diff)
downloadredmine-2714f6bcacb3ccd11f9bede09f97f5817bb7310d.tar.gz
redmine-2714f6bcacb3ccd11f9bede09f97f5817bb7310d.zip
remove trailing white-spaces from lib/tasks/locales.rake.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5724 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/locales.rake20
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/tasks/locales.rake b/lib/tasks/locales.rake
index 7b8efd470..7f7afa1a8 100644
--- a/lib/tasks/locales.rake
+++ b/lib/tasks/locales.rake
@@ -9,21 +9,21 @@ namespace :locales do
desc 'Updates language files based on en.yml content (only works for new top level keys).'
task :update 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|
puts "Updating file #{file}"
file_strings = YAML.load(File.read(file))
file_strings = file_strings[file_strings.keys.first]
-
+
missing_keys = en_strings.keys - file_strings.keys
next if missing_keys.empty?
-
+
puts "==> Missing #{missing_keys.size} keys (#{missing_keys.join(', ')})"
lang = File.open(file, 'a')
-
+
missing_keys.each do |key|
{key => en_strings[key]}.to_yaml.each_line do |line|
next if line =~ /^---/ || line.empty?
@@ -31,11 +31,11 @@ namespace :locales do
lang << " #{line}"
end
end
-
+
lang.close
end
end
-
+
desc 'Checks interpolation arguments in locals against en.yml'
task :check_interpolation do
dir = ENV['DIR'] || './config/locales'
@@ -44,7 +44,7 @@ namespace :locales do
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|
@@ -71,7 +71,7 @@ END_DESC
deletes = ENV['key'] ? Regexp.union(ENV['key'].split(',')) : nil
# Ignore multiline keys (begin with | or >) and keys with children (nothing meaningful after :)
delete_regex = /\A #{deletes}: +[^\|>\s#].*\z/
-
+
files.each do |path|
# Skip certain locales
(puts "Skipping #{path}"; next) if File.basename(path, ".yml") =~ skips
@@ -80,7 +80,7 @@ END_DESC
File.open(path, 'w') {|file| orig_content.each_line {|line| file.puts line unless line.chomp =~ delete_regex}}
end
end
-
+
desc <<-END_DESC
Adds a new top-level translation string to all locale file (only works for childless keys, probably doesn\'t work on windows, doesn't check for duplicates).