aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGareth Rees <gareth@mysociety.org>2014-12-11 15:16:34 +0000
committerGareth Rees <gareth@mysociety.org>2014-12-11 15:16:34 +0000
commitcef6acf0683da45c37d1669349c56b73d993c8df (patch)
tree8e9160e54b81a096cdb9bab0a496020f36ee06c3 /lib
parent667c5a294c971742d7b80b9f11d472f0d50a033e (diff)
Extract duplication in gettext theme tasks
Diffstat (limited to 'lib')
-rw-r--r--lib/tasks/gettext.rake21
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/tasks/gettext.rake b/lib/tasks/gettext.rake
index 6c88ebb7d..9bdb6169b 100644
--- a/lib/tasks/gettext.rake
+++ b/lib/tasks/gettext.rake
@@ -11,11 +11,7 @@ namespace :gettext do
desc "Update pot/po files for a theme."
task :find_theme => :environment do
- theme = ENV['THEME']
- unless theme
- puts "Usage: Specify an Alaveteli-theme with THEME=[theme directory name]"
- exit(0)
- end
+ theme = find_theme(ENV['THEME'])
load_gettext
msgmerge = Rails.application.config.gettext_i18n_rails.msgmerge
msgmerge ||= %w[--sort-output --no-location --no-wrap]
@@ -30,12 +26,7 @@ namespace :gettext do
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
-
+ theme = find_theme(ENV['THEME'])
load_gettext
Dir.glob("#{ theme_locale_path(theme) }/*/app.po") do |po_file|
@@ -44,6 +35,14 @@ namespace :gettext do
end
end
+ def find_theme(theme)
+ unless theme
+ puts "Usage: Specify an Alaveteli-theme with THEME=[theme directory name]"
+ exit(0)
+ end
+ theme
+ end
+
def theme_files_to_translate(theme)
Dir.glob("{lib/themes/#{theme}/lib}/**/*.{rb,erb}")
end