localize-0.2.0.1: GNU Gettext-based messages localization library
Safe HaskellNone
LanguageHaskell2010

Text.Localize.Load

Description

This module contains definitions for loading translation catalogs.

Synopsis

Data types

data LocatePolicy Source #

This data type defines where to search for catalog files (.mo or .gmo) in the file system.

Constructors

LocatePolicy 

Fields

  • lcBasePaths :: [FilePath]

    Paths to directory with translations, e.g. "/usr/share/locale". Defaults to "locale".

  • lcName :: String

    Catalog file name (in gettext this is also known as text domain). Defaults to "messages".

  • lcFacet :: Facet

    Locale facet. Defaults to LC_MESSAGES.

  • lcFormat :: Format

    File path format. The following variables can be used:

    • {base} - path to directory with translations;
    • {language} - language code;
    • {facet} - locale facet;
    • {name} - file name (text domain), without extension.

    Please note: assumption is made that the {language} variable is used only once.

    Defaults to "{base}/{language}/{facet}/{name}.mo".

Instances

Instances details
Show LocatePolicy Source # 
Instance details

Defined in Text.Localize.Load

Default LocatePolicy Source # 
Instance details

Defined in Text.Localize.Load

Methods

def :: LocatePolicy #

type Facet = String Source #

Locale facet (LC_MESSAGES and siblings).

Main functions

loadTranslations :: [(LanguageId, FilePath)] -> IO Translations Source #

Load translations when path to each translation file is known.

locateTranslations :: MonadIO m => LocatePolicy -> m Translations Source #

Locate and load translations according to specified policy.

Commonly used location policies

linuxLocation Source #

Arguments

:: String

Catalog file name (text domain)

-> LocatePolicy 

Usual Linux translations location policy. Catalog files are found under /usr/[local/]share/locale/{language}/LC_MESSAGES/{name}.mo.

localLocation Source #

Arguments

:: FilePath

Path to directory with translations

-> LocatePolicy 

Simple translations location polciy, assuming all catalog files located at {base}/{language}.mo.