fluent
Safe HaskellNone
LanguageHaskell2010

Language.Fluent.Translate

Synopsis

Documentation

data Reference Source #

A target message or attribute lookup. Also carries accumulated variadic parameters.

Constructors

Reference 

Instances

Instances details
IsString Reference Source #

Express a Reference as a string literal:

  • "message_id" targets a top-level message.
  • "message_id.attribute_name" targets a specific attribute.
Instance details

Defined in Language.Fluent.Translate

class Translate r where Source #

Brings together a message reference, any number of arguments, and a bundle to form a complete translation.

Instances of this class address three orthogonal concerns:

  • Argument collection. Messages may require arguments before they can be translated. These arguments may be passed directly or resolved implicitly from context.
  • Bundle resolution. Ultimately all translations come from a bundle. This bundle may be passed directly or resolved implicitly from context.
  • Return type. Determines a translation's output structure and its failure semantics.

Examples:

-- Explicit bundle with arguments, returning an Either for safe error handling.
result :: Either String Text
result = translate "welcome" ("name", "Alice") bundle
-- Rendering directly to a Miso View, which provides the bundle through the Context.
view :: View Context props model action
view = translate "title"

Methods

translate :: Reference -> r Source #

Instances

Instances details
Locale locale => Translate (Bundle locale -> Either String Text) Source # 
Instance details

Defined in Language.Fluent.Translate

Translate r => Translate (Override -> r) Source # 
Instance details

Defined in Language.Fluent.Translate

Methods

translate :: Reference -> Override -> r Source #

(k ~ Text, ToValue v, Translate r) => Translate ((k, v) -> r) Source # 
Instance details

Defined in Language.Fluent.Translate

Methods

translate :: Reference -> (k, v) -> r Source #

(Foldable f, k ~ Text, ToValue v, Translate r) => Translate (f (k, v) -> r) Source # 
Instance details

Defined in Language.Fluent.Translate

Methods

translate :: Reference -> f (k, v) -> r Source #