Class: YARD::I18n::Locale
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/yard/i18n/locale.rb |
Overview
Locale
is a unit of translation. It has #name and a set of
messages.
Class Attribute Summary
Class Method Summary
-
.new(name) ⇒ Locale
constructor
Creates a locale for #name locale.
Instance Attribute Summary
- #name ⇒ String readonly
Instance Method Summary
-
#load(locale_directory) ⇒ Boolean
Loads translation messages from +locale_directory+/#name.po.
- #translate(message) ⇒ String
Constructor Details
.new(name) ⇒ Locale
Creates a locale for #name locale.
Class Attribute Details
.default ⇒ String? (rw)
# File 'lib/yard/i18n/locale.rb', line 15
attr_accessor :default
.default=(locale) ⇒ String? (rw)
# File 'lib/yard/i18n/locale.rb', line 20
attr_accessor :default
Instance Attribute Details
#name ⇒ String (readonly)
# File 'lib/yard/i18n/locale.rb', line 29
attr_reader :name
Instance Method Details
#load(locale_directory) ⇒ Boolean
Loads translation messages from +locale_directory+/#name.po.
# File 'lib/yard/i18n/locale.rb', line 44
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
#translate(message) ⇒ String
# File 'lib/yard/i18n/locale.rb', line 62
def translate( ) @messages[ ] || end