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

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

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

Public Class methods

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

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-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.

Creates a new GetText::TextDomain.

  • name: the textdomain name.
  • topdir: the locale path ("%{topdir}/%{locale}/LC_MESSAGES/%{name}.mo").
  • locale: the Locale::Object or nil.
  • Returns: a newly created GetText::TextDomain object.

Public Instance methods

Gets the translated string.

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

Gets the translated string. (Deprecated. Don‘t call this method directly)

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

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.

Sets a new Locale::Object.

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

[Validate]