class RuboCop::Cop::Rails::ShortI18n


l Time.now
t :key
# good
localize Time.now
translate :key
# bad
@example EnforcedStyle: aggressive
l Time.now
t :key
localize Time.now
translate :key
# good
@example EnforcedStyle: conservative (default)
I18n.l Time.now
I18n.t :key
# good
I18n.localize Time.now
I18n.translate :key
# bad
@example
without a receiver are added as offenses.
When the EnforcedStyle is aggressive then all ‘translate` and `localize` calls
calls are added as offenses.
is conservative (the default) then only `I18n.translate` and `I18n.localize`
This cop has two different enforcement modes. When the EnforcedStyle
`t` instead of `translate` and `l` instead of `localize`.
Enforces that short forms of `I18n` methods are used:

def on_send(node)

def on_send(node)
  return if style == :conservative && !node.receiver
  long_i18n?(node) do |method_name|
    good_method = PREFERRED_METHODS[method_name]
    message = format(MSG, good_method: good_method, bad_method: method_name)
    range = node.loc.selector
    add_offense(range, message: message) do |corrector|
      corrector.replace(range, PREFERRED_METHODS[method_name])
    end
  end
end