module Gettext
Overview
Bindings for the GNU & Musl gettext library.
NOTE Documentation is meant to be viewed alongside the C one.
WARNING It goes without saying that both the locales and the text domains you input need to be available for the bindings to work.
Extended Modules
Defined in:
gettext.crInstance Method Summary
-
#bind_textdomain_codeset(domainname : String, codeset : String = "UTF-8") : String
Sets the current text domain's codeset.
-
#bindtextdomain(domainname : String, dirname : String | Path) : String
Sets the current text domain to a local one.
-
#dcgettext(domainname : String, msgid : String, category : LC) : String
Returns the translated msgid from the desired text domain and category.
-
#dcngettext(domainname : String, msgid1 : String, msgid2 : String, n : UInt32, category : LC) : String
Same as
#dcgettext
but supports plural forms. -
#dgettext(domainname : String, msgid : String) : String
Returns the translated msgid from the desired text domain.
-
#dngettext(domainname : String, msgid1 : String, msgid2 : String, n : UInt32) : String
Same as
#dgettext
but supports plural forms. -
#gettext(msgid : String) : String
Returns the translated msgid from the current text domain.
-
#ngettext(msgid1 : String, msgid2 : String, n : UInt32) : String
Same as
#gettext
but supports plural forms. -
#setlocale(category : LC = LC::ALL, locale : String = "") : String
Sets the current locale, overriding the one set by the env var / category.
-
#textdomain(domainname : String | Nil = nil) : String
Sets the current text domain to one that is already available.
Instance Method Detail
Sets the current text domain's codeset. If no parameters are provided, it sets it to UTF-8.
Returns the new codeset.
Example:
Gettext.bind_textdomain_codeset("my-domain", "UTF-8") # => "UTF-8"
Sets the current text domain to a local one.
Returns the new text domain.
Example:
Gettext.bindtextdomain("my-domain", ".") # => "."
Gettext.bindtextdomain("my-domain", Path[ENV["PWD"]]) # => "(pwd)"
Returns the translated msgid from the desired text domain and category.
Example:
Gettext.setlocale(Gettext::LC::ALL, "el_GR.UTF-8")
Gettext.dcgettext("gedit", "Text Editor", Gettext::LC::ALL) # => "Επεξεργαστής κειμένου"
Same as #dcgettext
but supports plural forms.
Example:
Gettext.dcngettext("gedit", "Crystal", "Crystals", 2, Gettext::LC::ALL) # => "Crystals"
Returns the translated msgid from the desired text domain.
Example:
Gettext.setlocale(Gettext::LC::ALL, "el_GR.UTF-8")
Gettext.dgettext("gedit", "Text Editor") # => "Επεξεργαστής κειμένου"
Same as #dgettext
but supports plural forms.
Example:
Gettext.dngettext("gedit", "Crystal", "Crystals", 2) # => "Crystals"
Returns the translated msgid from the current text domain.
Example:
Gettext.setlocale(Gettext::LC::ALL, "el_GR.UTF-8")
Gettext.textdomain("gedit")
Gettext.gettext("Text Editor") # => "Επεξεργαστής κειμένου"
Same as #gettext
but supports plural forms.
Example:
Gettext.ngettext("Crystal", "Crystals", 2) # => "Crystals"
Sets the current locale, overriding the one set by the env var / category. If no parameters are provided, it sets LC:ALL to "".
Returns the new locale or all categories.
Example:
Gettext.setlocale(Gettext::LC::ALL, "el_GR.UTF-8") # => "el_GR.UTF-8"
Sets the current text domain to one that is already available. If no parameters are provided, it returns the current one.
Returns the new (or current) text domain.
Example:
Gettext.textdomain("gedit") # => "gedit"
Gettext.textdomain # => "gedit"