module I18n::Processes::Scanners::RubyKeyLiterals

Constants

LITERAL_RE
VALID_KEY_CHARS
VALID_KEY_RE

Public Instance Methods

literal_re() click to toggle source

Match literals:

  • String: '', “#{}”

  • Symbol: :sym, :'', :“#{}”

# File lib/i18n/processes/scanners/ruby_key_literals.rb, line 10
def literal_re
  LITERAL_RE
end
strip_literal(literal) click to toggle source

remove the leading colon and unwrap quotes from the key match @param literal [String] e.g: “key”, 'key', or :key. @return [String] key

# File lib/i18n/processes/scanners/ruby_key_literals.rb, line 17
def strip_literal(literal)
  literal = literal[1..-1] if literal[0] == ':'
  literal = literal[1..-2] if literal[0] == "'" || literal[0] == '"'
  literal
end
valid_key?(key) click to toggle source
# File lib/i18n/processes/scanners/ruby_key_literals.rb, line 26
def valid_key?(key)
  key =~ VALID_KEY_RE && !key.end_with?('.')
end