class YARD::I18n::Locale

@since 0.8.2
messages.
Locale is a unit of translation. It has {#name} and a set of

def default

def default
  @@default ||= nil
end

def default=(locale)

def default=(locale)
  @@default = locale
end

def initialize(name)

Parameters:
  • name (String) -- the locale name.
def initialize(name)
  @name = name
  @messages = {}
end

def load(locale_directory)

Returns:
  • (Boolean) - +true+ if PO file exists, +false+ otherwise.

Parameters:
  • locale_directory (String) -- the directory path that has
def load(locale_directory)
  return false if @name.nil?
  po_file = File.join(locale_directory, "#{@name}.po")
  return false unless File.exist?(po_file)
  require "yard/i18n/po_parser"
  return false unless POParser.available?
  po_parser = POParser.new
  @messages.merge!(po_parser.parse(po_file))
  true
end

def translate(message)

Returns:
  • (String) - translated message. If translation isn't

Parameters:
  • message (String) -- the translation target message.
def translate(message)
  @messages[message] || message
end