struct

Gettext::POBackend

Inherits Struct / Value / Object

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

Constructors

new(locale_directory_path : String)

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

NOTE Any files that has the same name is assumed to be apart of the same locale since we don't know the specific language header for them yet.

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

Instance methods

create

Create message catalogue from the loaded locale files

Shortcut to avoid calling scan and parse

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 po file name is used as a fallback.

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

Parse tokens 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 po file name is used as a fallback.

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

Scans loaded locale data into tokens parsing.

Returned as a mapping of the po file name to the token array

backend = Gettext::POBackend.new("locales")
backend.scan # => Array(Token)
Source