Class: GetText::TextDomain

Class GetText::TextDomain |
In: | lib/gettext/textdomain.rb
Parent: | Object

GetText::TextDomain class manages mo-files of a textdomain.

Usually, you don’t need to use this class directly.

Notice: This class is unstable. APIs will be changed.

Methods

- add_default_locale_path
- check_mo=
- check_mo?
- gettext
- new
- ngettext
- same_property?
- set_locale

Constants

CONFIG_PREFIX | = | Config::CONFIG['prefix'].gsub(/\/local/, "")
| The default locale paths.
DEFAULT_LOCALE_PATHS | = | [ "#{Config::CONFIG['datadir']}/locale/%{locale}/LC_MESSAGES/%{name}.mo", "#{Config::CONFIG['datadir'].gsub(/\/local/, "")}/locale/%{locale}/LC_MESSAGES/%{name}.mo", "#{CONFIG_PREFIX}/share/locale/%{locale}/LC_MESSAGES/%{name}.mo", "#{CONFIG_PREFIX}/local/share/locale/%{locale}/LC_MESSAGES/%{name}.mo"

Attributes

[R] | current_locale |
[R] | current_mo |
[R] | locale_paths |
[R] | name |

Public Class methods
add_default_locale_path(path) [ source ]

Add default locale path. Usually you should use GetText.add_default_locale_path instead.

- path: a new locale path. (e.g.) "/usr/share/locale/%{locale}/LC_MESSAGES/%{name}.mo" (‘locale’ => "ja_JP", ‘name’ => "textdomain")
- Returns: the new DEFAULT_LOCALE_PATHS

check_mo=(val) [ source ]

Sets to check mo-file or not. See GetText::TextDoman.check_mo? for more details.

- val: true if "check mo" mode.
- Returns: val

check_mo?() [ source ]

Check mo-file is modified or not, and if mo-file is modified, reload mo-file again. This is effective in debug mode. Default is false. If $DEBUG is true, mo-file is checked even if this value is false.

- Returns: true if "check mo" mode.

new(name, topdir = nil, locale = nil) [ source ]

Creates a new GetText::TextDomain.

- name: the textdomain name.
- topdir: the top directory of mo files or nil.
- locale: the Locale::Object or nil.
- Returns: a newly created GetText::TextDomain object.

Public Instance methods
gettext(msgid) [ source ]

Gets the translated string.

- msgid: the original message.
- Returns: the translated string or nil if not found.

ngettext(msgid, msgid_plural, n) [ source ]

Gets the translated string.

- msgid: the original message(single).
- msgid: the original message(plural).
- n: the number
- Returns: the translated string or nil if not found.

same_property?(name, topdir, locale) [ source ]

Compare this object has the same name, topdir and locale.

- name: the textdomain name
- topdir: the top directory of mo files or nil.
- locale: the Locale::Object or nil.
- Returns: true if this object has all of the same name, topdir and locale.

set_locale(locale, reload = false) [ source ]

Sets a new Locale::Object.

- locale: a Locale::Object
- reload: true if the mo-file is reloaded forcely
- Returns: self