struct

Gettext::MOBackend

Inherits Struct / Value / Object

The backend for Gettext's MO files. This class contains methods to parse and interact with them.

Similar to the Gettext module from Python, feel free to subclass and override the #parse method to create a backend for other .mo files. However, please consider opening a PR and adding it directly to lens instead!

Constants

BE_MAGIC = 3725722773_i64
LE_MAGIC = 2500072158_i64

Constructors

new(locale_directory_path : String)

Create a new MO backend instance that reads from the given locale directory path

Gettext::MOBackend.new("locales")
Source

Instance methods

create

Create message catalogue from the loaded locale files.

This is the equivalent to parse and is only here for compatibility with Gettext::POBackend

This is returned as a mapping of the language code to the catalogue in which the language code is taken from the Language header. If none can be found then the mo file name is used as a fallback.

backend = Gettext::MOBackend.new("locales")
backend.create # => Hash(String, Catalogue)
Source
parse

Parse gettext mo files into message catalogues.

This is returned as a mapping of the language code to the catalogue in which the language code is taken from the Language header. If none can be found then the mo file name is used as a fallback.

backend = Gettext::MOBackend.new("locales")
backend.parse # => Hash(String, Catalogue)
Source