class I18n::Hygiene::Checks::UnexpectedReturnSymbol

Looks for unexpected return symbols (U+23CE) in translations.

This check is fairly specific to PhraseApp, where U+23CE has special meaning.

Constants

RETURN_SYMBOL_REGEX

Public Instance Methods

run() { |result(:failure, message: message)| ... } click to toggle source
# File lib/i18n/hygiene/checks/unexpected_return_symbol.rb, line 16
def run
  wrapper = I18n::Hygiene::Wrapper.new(locales: all_locales, exclude_scopes: config.exclude_scopes)
  keys_with_return_symbols = I18n::Hygiene::KeysWithMatchedValue.new(RETURN_SYMBOL_REGEX, wrapper)

  keys_with_return_symbols.each do |locale, key|
    message = ErrorMessageBuilder.new
      .title("Unexpected return symbol (U+23CE)")
      .locale(locale)
      .key(key)
      .translation(wrapper.value(locale, key))
      .create

    yield Result.new(:failure, message: message)
  end
end