Copyright (C) 2012-2013 Kouhei Sutou <kou@clear-code.com>
License: Ruby‘s or LGPL
This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <www.gnu.org/licenses/>.
VERSION | = | "3.2.9" |
makes dynamic translation messages readable for the gettext parser. _(fruit) cannot be understood by the gettext parser. To help the parser find all your translations, you can add fruit = N_("Apple") which does not translate, but tells the parser: "Apple" needs translation.
bindtextdomain(domainname, options = {})
Bind a text domain(%{path}/%{locale}/LC_MESSAGES/%{domainname}.mo) to your program. Normally, the texdomain scope becomes the class/module(and parent classes/included modules).
Includes GetText module and bind a text domain to a class.
Gets the CGI object. If it is nil, returns new CGI object. This methods is appeared when requiring "gettext/cgi".
Same as GetText.set_cgi. This methods is appeared when requiring "gettext/cgi".
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}") % {:val => "world"}
Because the translator may want to change the position of "world".
The ngettext is similar to the gettext function as it finds the message catalogs in the same way. But it takes two extra arguments for plural form.
The npgettext is similar to the nsgettext function.
e.g.) np_("Special", "An apple", "%{num} Apples", num) == ns_("Special|An apple", "%{num} Apples", num)
The nsgettext is similar to the ngettext. But if there are no localized text, it returns a last part of msgid separeted "div".
Gets the current output_charset which is set using GetText.set_output_charset.
Translates msgid with msgctxt. This methods is similer with s_().
e.g.) p_("File", "New") == s_("File|New") p_("File", "Open") == s_("File|Open")
See: www.gnu.org/software/autoconf/manual/gettext/Contexts.html
Sets a CGI object. This methods is appeared when requiring "gettext/cgi".
Set the locale to the current thread. Note that if set_locale is set, this value is ignored. If you need, set_locale(nil); set_current_locale(lang)
Sets charset(String) such as "euc-jp", "sjis", "CP932", "utf-8", … You shouldn‘t use this in your own Libraries.
Translates msgid, but if there are no localized text, it returns a last part of msgid separeted "div".
See: www.gnu.org/software/gettext/manual/html_mono/gettext.html#SEC151