frozen_string_literal: false
An i18n supported text.
This object provides the following two features:
* Extracts translation messages from wrapped raw text.
* Translates wrapped raw text in specified locale.
Wrapped raw text is one of String, RDoc::Comment or Array of them.
Methods
- E
- N
- T
Class Public methods
new(raw)
Link
Creates a new i18n supported text for raw text.
Instance Public methods
extract_messages()
Link
Extracts translation target messages and yields each message.
Each yielded message is a Hash. It consists of the followings:
- :type
-
:paragraph
- :paragraph
-
String (The translation target message itself.)
- :line_no
-
Integer (The line number of the :paragraph is started.)
The above content may be added in the future.
translate(locale)
Link
Translates raw text into locale.
# File lib/rdoc/i18n/text.rb, line 44 def translate(locale) translated_text = '' parse do |part| case part[:type] when :paragraph translated_text << locale.translate(part[:paragraph]) when :empty_line translated_text << part[:line] else raise "should not reach here: unexpected type: #{type}" end end translated_text end