aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGareth Rees <gareth@mysociety.org>2014-12-11 15:14:16 +0000
committerGareth Rees <gareth@mysociety.org>2014-12-11 15:14:16 +0000
commit667c5a294c971742d7b80b9f11d472f0d50a033e (patch)
tree9158af924f4ecab5e3c351bf7f215a17c147a181
parent2965acf903261301a28bf39dce67f1635ca208b3 (diff)
Add task to clean theme translations
-rw-r--r--lib/tasks/gettext.rake16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/tasks/gettext.rake b/lib/tasks/gettext.rake
index 3f357213f..6c88ebb7d 100644
--- a/lib/tasks/gettext.rake
+++ b/lib/tasks/gettext.rake
@@ -28,6 +28,22 @@ namespace :gettext do
)
end
+ desc 'Rewrite theme .po files into a consistent msgmerge format'
+ task :clean_theme do
+ theme = ENV['THEME']
+ unless theme
+ puts "Usage: Specify an Alaveteli-theme with THEME=[theme directory name]"
+ exit(0)
+ end
+
+ load_gettext
+
+ Dir.glob("#{ theme_locale_path(theme) }/*/app.po") do |po_file|
+ GetText::msgmerge(po_file, po_file, 'alaveteli',
+ :msgmerge => [:sort_output, :no_location, :no_wrap])
+ end
+ end
+
def theme_files_to_translate(theme)
Dir.glob("{lib/themes/#{theme}/lib}/**/*.{rb,erb}")
end