Method: GetText#gettext

Defined in:
lib/gettext.rb

#gettext(msgid) ⇒ Object Also known as: _

call-seq: gettext(msgid) _(msgid)

Translates msgid and return the message. This doesn't make a copy of the message.

You need to use String#dup if you want to modify the return value with destructive functions.

(e.g.1) _("Hello ").dup << "world"

But e.g.1 should be rewrite to:

(e.g.2) _("Hello %val") % => "world"

Because the translator may want to change the position of "world".

  • msgid: the message id.
  • Returns: localized text by msgid. If there are not binded mo-file, it will return msgid.


117
118
119
# File 'lib/gettext.rb', line 117

def gettext(msgid)
  TextDomainManager.translate_singular_message(self, msgid)
end