BOM_UTF8 | = | [0xef, 0xbb, 0xbf].pack("c3") |
VERSION | = | "2.0.4" |
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 textdomain(%{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 textdomain 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".
Creates mo-files using #{po_root}/#{lang}/*.po an put them to #{targetdir}/#{targetdir_rule}/.
This is a convenience function of GetText.rmsgfmt for multiple target files.
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".
Merges two Uniforum style .po files together.
Note This function requires "msgmerge" tool included in GNU GetText. So you need to install GNU GetText.
The def.po file is an existing PO file with translations which will be taken over to the newly created file as long as they still match; comments will be preserved, but extracted comments and file positions will be discarded.
The ref.pot file is the last created PO file with up-to-date source references but old translations, or a PO Template file (generally created by rgettext); any translations or comments in the file will be discarded, however dot comments and file positions will be preserved. Where an exact match cannot be found, fuzzy matching is used to produce better results.
Usually you don‘t need to call this function directly. Use GetText.update_pofiles instead.
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
Creates a po-file from targetfiles(ruby-script-files, .rhtml files, glade-2 XML files), then output the result to out. If no parameter is set, it behaves same as command line tools(rgettet).
This function is a part of GetText.create_pofiles. Usually you don‘t need to call this function directly.
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
At first, this creates the #{po_root}/#{domainname}.pot file using GetText.rgettext. In the second step, this updates(merges) the #{po_root}/#{domainname}.pot and all of the #{po_root}/#{lang}/#{domainname}.po files under "po_root" using "msgmerge".
Note "msgmerge" tool is included in GNU GetText. So you need to install GNU GetText.
See <HOWTO maintain po/mo files(www.yotabanana.com/hiki/ruby-gettext-howto-manage.html)> for more detals.
:lang - update files only for one language - the language specified by this option :po_root - the root directory of po-files :msgmerge - an array with the options, passed through to the gnu msgmerge tool symbols are automatically translated to options with dashes, example: [:no_wrap, :no_fuzzy_matching, :sort_output] translated to '--no-fuzzy-matching --sort-output' :verbose - true to show verbose messages. default is false.
Example: GetText.update_pofiles("myapp", Dir.glob("lib/*.rb"), "myapp 1.0.0", :verbose => true)