Skip to content

Commit

Permalink
Add rake tolk:html_keys for finding html phrases without _html postfix
Browse files Browse the repository at this point in the history
  • Loading branch information
lifo committed Apr 29, 2010
1 parent f3fc2d1 commit 58e78ee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/models/tolk/locale.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@ def [](key)
end
end

def translations_with_html
translations = self.translations.all(:conditions => "tolk_translations.text LIKE '%>%' AND
tolk_translations.text LIKE '%<%' AND tolk_phrases.key NOT LIKE '%_html'", :joins => :phrase)
Translation.send :preload_associations, translations, :phrase
translations
end

private

def remove_invalid_translations_from_target
Expand Down
7 changes: 7 additions & 0 deletions tasks/tolk_tasks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,11 @@ namespace :tolk do
Tolk::Locale.import_secondary_locales
end

desc "Show all the keys potentially containing HTML values and no _html postfix"
task :html_keys => :environment do
bad_translations = Tolk::Locale.primary_locale.translations_with_html
bad_translations.each do |bt|
puts "#{bt.phrase.key} - #{bt.text}"
end
end
end

0 comments on commit 58e78ee

Please sign in to comment.