aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tasks
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2013-09-12 14:45:14 +0100
committerLouise Crow <louise.crow@gmail.com>2013-09-12 14:45:14 +0100
commit1e81e07d1337f76f3ed00b6f71f5c2e491cae5cf (patch)
tree15a42aa5e0098646d8f72527337ab222d59eb85f /lib/tasks
parentbefbcbc36f75a5d00ea26d99e7980d214835b2af (diff)
Add simple task for updating theme translations.
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/gettext.rake26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/tasks/gettext.rake b/lib/tasks/gettext.rake
index 31893f1b8..366dfbe88 100644
--- a/lib/tasks/gettext.rake
+++ b/lib/tasks/gettext.rake
@@ -9,5 +9,31 @@ namespace :gettext do
end
end
+ 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
+ load_gettext
+ msgmerge = Rails.application.config.gettext_i18n_rails.msgmerge
+ msgmerge ||= %w[--sort-output --no-location --no-wrap]
+ GetText.update_pofiles_org(
+ text_domain,
+ theme_files_to_translate(theme),
+ "version 0.0.1",
+ :po_root => theme_locale_path(theme),
+ :msgmerge => msgmerge
+ )
+ end
+
+ def theme_files_to_translate(theme)
+ Dir.glob("{vendor/plugins/#{theme}/lib}/**/*.{rb,erb}")
+ end
+
+ def theme_locale_path(theme)
+ File.join(Rails.root, "vendor", "plugins", theme, "locale-theme")
+ end
end