aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/gettext.rake42
-rw-r--r--lib/tasks/stats.rake9
2 files changed, 30 insertions, 21 deletions
diff --git a/lib/tasks/gettext.rake b/lib/tasks/gettext.rake
index ace7205ae..366dfbe88 100644
--- a/lib/tasks/gettext.rake
+++ b/lib/tasks/gettext.rake
@@ -9,27 +9,31 @@ namespace :gettext do
end
end
- desc "Update pot file only, without fuzzy guesses (these are done by Transifex)"
- task :findpot => :environment 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
load_gettext
- $LOAD_PATH << File.join(File.dirname(__FILE__),'..','..','lib')
- require 'gettext_i18n_rails/haml_parser'
- files = files_to_translate
+ 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
- #write found messages to tmp.pot
- temp_pot = "tmp.pot"
- GetText::rgettext(files, temp_pot)
+ def theme_files_to_translate(theme)
+ Dir.glob("{vendor/plugins/#{theme}/lib}/**/*.{rb,erb}")
+ end
- #merge tmp.pot and existing pot
- FileUtils.mkdir_p('locale')
- GetText::msgmerge("locale/app.pot", temp_pot, "alaveteli", :po_root => 'locale', :msgmerge=>[ :no_wrap, :sort_output ])
- Dir.glob("locale/*/app.po") do |po_file|
- GetText::msgmerge(po_file, temp_pot, "alaveteli", :po_root => 'locale', :msgmerge=>[ :no_wrap, :sort_output ])
- end
- File.delete(temp_pot)
- end
+ def theme_locale_path(theme)
+ File.join(Rails.root, "vendor", "plugins", theme, "locale-theme")
+ end
- def files_to_translate
- Dir.glob("{app,lib,config,locale}/**/*.{rb,erb,haml,rhtml}")
- end
end
diff --git a/lib/tasks/stats.rake b/lib/tasks/stats.rake
index 1242575fe..4eda27289 100644
--- a/lib/tasks/stats.rake
+++ b/lib/tasks/stats.rake
@@ -93,8 +93,10 @@ namespace :stats do
desc 'Update statistics in the public_bodies table'
task :update_public_bodies_stats => :environment do
+ verbose = ENV['VERBOSE'] == '1'
PublicBody.all.each do |public_body|
- puts "Counting overdue requests for #{public_body.name}"
+ puts "Counting overdue requests for #{public_body.name}" if verbose
+
# Look for values of 'waiting_response_overdue' and
# 'waiting_response_very_overdue' which aren't directly in the
# described_state column, and instead need to be calculated:
@@ -109,7 +111,10 @@ namespace :stats do
end
end
public_body.info_requests_overdue_count = overdue_count + very_overdue_count
- public_body.save!
+ public_body.no_xapian_reindex = true
+ public_body.without_revision do
+ public_body.save!
+ end
end
end
end