i18n-0.4.0.0: Internationalization for Haskell

Copyright(c) 2011-2016 Eugene Grigoriev
LicenseBSD3
MaintainerPhilip Cunningham <hello@filib.io>
Stabilityexperimental
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Text.I18n.Po

Contents

Description

This module contains the PO parser. PO files are assumed to be in UTF-8 encoding. Plural forms are not yet implemented.

Synopsis

PO parsing

getL10n Source

Arguments

:: FilePath

Directory containing PO files.

-> IO (L10n, [ParseError])

Localization structure and a list of parse errors.

Builds L10n structure by parsing .po files contained in a given directory. L10n structure is to be passed to localize function. L10n structure is used internaly by the I18n monad.

I18n Monad Functions

localize Source

Arguments

:: L10n

Structure containing localization data

-> Locale

Locale to use

-> I18n a

Inernationalized expression

-> a

Localized expression

Top level localization function.

Examples:

>>> I18n.localize l10n (I18n.Locale "cym") example
"Fel dagrau yn y glaw."

When the translation doesn't exist:

>>> I18n.localize l10n (I18n.Locale "ru") example
"Like tears in rain."

gettext :: Text -> I18n Text Source

withContext Source

Arguments

:: Maybe Context

Context to use

-> I18n a

Internationalized expression

-> I18n a

New internationalized expression

Sets a local Context for an internationalized expression. If there is no translation, then no context version is tried.

Examples:

>>> let example2 = I18n.withContext (Just "Attack ships on fire off the shoulder of Orion.") example
>>> I18n.localize l10n (I18n.Locale "cym") example2
"Fel dagrau yn y glaw."

withLocale Source

Arguments

:: Locale

Locale to use

-> I18n a

Internationalized expression

-> I18n a

New internationalized expression.

Sets a local Locale for an internationalized expression.

Examples:

>>> let example3 = I18n.withLocale (I18n.Locale "en") example
>>> I18n.localize l10n (I18n.Locale "cym") example3
"Like tears in rain."

Parsing functions

parsePo :: FilePath -> IO (Either ParseError [MsgDec]) Source