class I18n::Hygiene::Checks::HtmlEntity
Looks for unexpected HTML entities (‘&`, `!`) in translations.
Constants
- ENTITY_REGEX
Public Instance Methods
run() { |result(:failure, message: message)| ... }
click to toggle source
# File lib/i18n/hygiene/checks/html_entity.rb, line 15 def run wrapper = I18n::Hygiene::Wrapper.new(locales: all_locales, exclude_scopes: config.exclude_scopes) keys_with_entities = I18n::Hygiene::KeysWithMatchedValue.new(ENTITY_REGEX, wrapper, reject_keys: reject_keys) keys_with_entities.each do |locale, key| message = ErrorMessageBuilder.new .title("Unexpected HTML entity") .locale(locale) .key(key) .translation(wrapper.value(locale, key)) .create yield Result.new(:failure, message: message) end end
Private Instance Methods
reject_keys()
click to toggle source
# File lib/i18n/hygiene/checks/html_entity.rb, line 34 def reject_keys Proc.new { |key| key.end_with?("_html") || key.end_with?("_markdown") } end