From 63871baf6061668b162972193c55b5a8f7490797 Mon Sep 17 00:00:00 2001 From: elijah Date: Thu, 30 Apr 2015 00:32:33 -0700 Subject: added support for email notifications of ticket changes --- lib/tasks/i18n.rake | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) (limited to 'lib/tasks') diff --git a/lib/tasks/i18n.rake b/lib/tasks/i18n.rake index daa1834..5ccc65e 100644 --- a/lib/tasks/i18n.rake +++ b/lib/tasks/i18n.rake @@ -1,6 +1,19 @@ require 'yaml' require 'fileutils' +def process_locale_file(output, file) + ## print separator to see where another file begins + output.write("\n\n" + '#' * 40 + "\n" + '### ' + file + "\n") + output.write( + # remove the toplevel "en" key + YAML.dump(YAML.load_file(file)['en']).lines.map { + |line| " #{line}" # << prefix all lines with two spaces (we're nested below "en:") + }[ + 1..-1 # << skip the first line (it's "---" and freaks out the parser if it sees it multiple times in a file) + ].join + ) +end + namespace :i18n do # # for coding, it helps to have the english strings in separate files. @@ -14,27 +27,20 @@ namespace :i18n do desc "combine config/locales/*.en.yml to lib/en_US.yml" task :bundle do en_yml = File.join(Rails.root, 'lib', 'en_US.yml') - Dir.chdir('config/locales/') do - if File.exists?(en_yml) - File.unlink en_yml - end - File.open(en_yml, 'w') do |output| - output.write("en_US:\n\n"+ - "### Do NOT edit this file directly, as all changes will be overwritten by `rake i18:bundle`\n"+ - "### Instead, make changes in the appropriate file in config/locales.\n"+ - "### Source strings in transifex are automatically updated from this file (via github url)") + File.open(en_yml, 'w') do |output| + output.write("en_US:\n\n"+ + "### Do NOT edit this file directly, as all changes will be overwritten by `rake i18n:bundle`\n"+ + "### Instead, make changes in the appropriate file in config/locales.\n"+ + "### Source strings in transifex are automatically updated from this file (via github url)") + Dir.chdir('config/locales/') do Dir.glob('*.en.yml').sort.each do |file| - ## print separator to see where another file begins - output.write("\n\n" + '#' * 40 + "\n" + '### ' + file + "\n") - output.write( - # remove the toplevel "en" key - YAML.load_file(file)['en']. - to_yaml. - # prefix all lines with two spaces (we're nested below "en:") - lines.map {|line| " #{line}"}[ - 1..-1 # << skip the first line (it's "---" and freaks out the parser if it sees it multiple times in a file) - ].join) + process_locale_file(output, file) + end + end + Dir.chdir('engines/') do + Dir.glob('*/config/locales/en.yml').sort.each do |file| + process_locale_file(output, file) end end puts "You can now find the bundled locale yml in: #{en_yml}" -- cgit v1.2.3