module GetText::RubyParser

Constants

ID
MSGCTXT_ID
MSGCTXT_PLURAL_ID
PLURAL_ID

Public Instance Methods

detect_encoding(source) click to toggle source
# File lib/gettext/tools/parser/ruby.rb, line 133
def detect_encoding(source)
  return nil unless source.respond_to?(:force_encoding)
  binary_source = source.dup.force_encoding("ASCII-8BIT")
  if %r\A.*coding\s*[=:]\s*([[:alnum:]\-_]+)/ =~ binary_source
    $1.gsub(%r-(?:unix|mac|dos)\z/, "")
  else
    nil
  end
end