Fixes the language codes in the pull_translations script

This commit is contained in:
Gerhard Schlager 2015-05-06 17:03:07 +02:00
parent 6447c6c81d
commit dc8759962b
1 changed files with 7 additions and 3 deletions

View File

@ -51,10 +51,14 @@ YML_DIRS = ['config/locales',
['client', 'server'].each do |base| ['client', 'server'].each do |base|
YML_DIRS.each do |dir| YML_DIRS.each do |dir|
Dir.glob(File.expand_path("../../#{dir}/#{base}.*.yml", __FILE__)).each do |file_name| Dir.glob(File.expand_path("../../#{dir}/#{base}.*.yml", __FILE__)).each do |file_name|
contents = File.readlines(file_name) language = File.basename(file_name).match(Regexp.new("#{base}\\.([^\\.]*)\\.yml"))[1]
lines = File.readlines(file_name)
lines.collect! {|line| line =~ /^[a-z_]+:$/i ? "#{language}:" : line}
File.open(file_name, 'w+') do |f| File.open(file_name, 'w+') do |f|
f.puts(YML_FILE_COMMENTS, '') unless contents[0][0] == '#' f.puts(YML_FILE_COMMENTS, '') unless lines[0][0] == '#'
f.puts contents f.puts(lines)
end end
end end
end end