fluent
Copyright(c) 2026 Institute for Digital Autonomy
LicenseEUPL-1.2
MaintainerIDA
Safe HaskellTrustworthy
LanguageHaskell2010

Language.Fluent

Description

Project Fluent is a localisation system designed to unleash the entire expressive power of natural language translations.

This library provides the core Fluent translation machinery to go from parsed Resources to translated messages:

  • the Locale typeclass which supplies locale-specific operations
  • the Bundle type which combines Locales with parsed Resources
  • the Translate typeclass which translates messages from a Bundle

This library does not provide any concrete instances of Locale. It is not intended to be used directly for translating messages.

Applications should instead use a library built on top of this one, such as:

Synopsis

Documentation

data Identifier #

The name of a Message, Term, Attribute, variable, function, or named argument.

Instances

Instances details
Show Identifier 
Instance details

Defined in Language.Fluent.AST

Eq Identifier 
Instance details

Defined in Language.Fluent.AST

Ord Identifier 
Instance details

Defined in Language.Fluent.AST

Hashable Identifier 
Instance details

Defined in Language.Fluent.AST

Lift Identifier 
Instance details

Defined in Language.Fluent.TH

Methods

lift :: Quote m => Identifier -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => Identifier -> Code m Identifier #

data Resource #

An entire FTL file

Instances

Instances details
Generic Resource 
Instance details

Defined in Language.Fluent.AST

Associated Types

type Rep Resource 
Instance details

Defined in Language.Fluent.AST

type Rep Resource = D1 ('MetaData "Resource" "Language.Fluent.AST" "fluent-syntax-1.0.0-7BgVkF4w5nsLx3MmJftb3I" 'True) (C1 ('MetaCons "Resource" 'PrefixI 'True) (S1 ('MetaSel ('Just "entries") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Entry])))

Methods

from :: Resource -> Rep Resource x #

to :: Rep Resource x -> Resource #

Show Resource 
Instance details

Defined in Language.Fluent.AST

Eq Resource 
Instance details

Defined in Language.Fluent.AST

Lift Resource 
Instance details

Defined in Language.Fluent.TH

Methods

lift :: Quote m => Resource -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => Resource -> Code m Resource #

type Rep Resource 
Instance details

Defined in Language.Fluent.AST

type Rep Resource = D1 ('MetaData "Resource" "Language.Fluent.AST" "fluent-syntax-1.0.0-7BgVkF4w5nsLx3MmJftb3I" 'True) (C1 ('MetaCons "Resource" 'PrefixI 'True) (S1 ('MetaSel ('Just "entries") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Entry])))

data Bundle locale Source #

A collection of Fluent resources and the configuration needed to resolve and format messages for a locale.

Constructors

Bundle 

Fields

Instances

Instances details
Locale locale => Show (Bundle locale) Source # 
Instance details

Defined in Language.Fluent.Bundle

Methods

showsPrec :: Int -> Bundle locale -> ShowS #

show :: Bundle locale -> String #

showList :: [Bundle locale] -> ShowS #

Locale locale => Eq (Bundle locale) Source #

Only the names of the functions are compared, since their implementations cannot be compared for equality.

Instance details

Defined in Language.Fluent.Bundle

Methods

(==) :: Bundle locale -> Bundle locale -> Bool #

(/=) :: Bundle locale -> Bundle locale -> Bool #

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

Defined in Language.Fluent.Translate

data Override Source #

Instances

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

Defined in Language.Fluent.Translate

Methods

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

bundle :: NonEmpty locale -> [Resource] -> Bundle locale Source #

data Style Source #

What a number denotes, which determines how it is formatted.

Constructors

Decimal

A plain number: 12.5

Percent

A ratio, shown as a percentage: 1,250%

Currency Text

An amount of the currency with the given ISO 4217 code: Currency EUR gives €12.50

Unit Text

A measurement in the given CLDR unit: Unit "second" gives 12.5 s

Instances

Instances details
Show Style Source # 
Instance details

Defined in Language.Fluent.Number

Methods

showsPrec :: Int -> Style -> ShowS #

show :: Style -> String #

showList :: [Style] -> ShowS #

Eq Style Source # 
Instance details

Defined in Language.Fluent.Number

Methods

(==) :: Style -> Style -> Bool #

(/=) :: Style -> Style -> Bool #

newtype Pattern Source #

A Pattern with all the selections and interpolations resolved down to SomeValue and isolation marks.

Instances

Instances details
Value Pattern Source # 
Instance details

Defined in Language.Fluent.Pattern

Semigroup Pattern Source # 
Instance details

Defined in Language.Fluent.Pattern

IsString Pattern Source # 
Instance details

Defined in Language.Fluent.Pattern

Methods

fromString :: String -> Pattern #

Show Pattern Source # 
Instance details

Defined in Language.Fluent.Pattern

data PatternElement Source #

A single piece of a Pattern.

Constructors

Value SomeValue

A value, ready to be formatted.

Isolated Pattern

A sequence of values surrounded by isolation marks (FSI, PDI).

data Form Source #

Constructors

Cardinal 
Ordinal 

Instances

Instances details
Bounded Form Source # 
Instance details

Defined in Language.Fluent.Plural

Enum Form Source # 
Instance details

Defined in Language.Fluent.Plural

Methods

succ :: Form -> Form #

pred :: Form -> Form #

toEnum :: Int -> Form #

fromEnum :: Form -> Int #

enumFrom :: Form -> [Form] #

enumFromThen :: Form -> Form -> [Form] #

enumFromTo :: Form -> Form -> [Form] #

enumFromThenTo :: Form -> Form -> Form -> [Form] #

Read Form Source # 
Instance details

Defined in Language.Fluent.Plural

Show Form Source # 
Instance details

Defined in Language.Fluent.Plural

Methods

showsPrec :: Int -> Form -> ShowS #

show :: Form -> String #

showList :: [Form] -> ShowS #

Eq Form Source # 
Instance details

Defined in Language.Fluent.Plural

Methods

(==) :: Form -> Form -> Bool #

(/=) :: Form -> Form -> Bool #

data Digits Source #

How many digits a date or time field takes, e.g. the ninth month is 9 when Numeric and 09 when TwoDigit.

Constructors

Numeric 
TwoDigit 

Instances

Instances details
Bounded Digits Source # 
Instance details

Defined in Language.Fluent.Time

Enum Digits Source # 
Instance details

Defined in Language.Fluent.Time

Read Digits Source # 
Instance details

Defined in Language.Fluent.Time

Show Digits Source # 
Instance details

Defined in Language.Fluent.Time

Eq Digits Source # 
Instance details

Defined in Language.Fluent.Time

Methods

(==) :: Digits -> Digits -> Bool #

(/=) :: Digits -> Digits -> Bool #

data Width Source #

Constructors

Narrow

e.g. A, 5s

Short

e.g. Aug, 5 s

Long

e.g. August, 5 seconds

Instances

Instances details
Bounded Width Source # 
Instance details

Defined in Language.Fluent.Width

Enum Width Source # 
Instance details

Defined in Language.Fluent.Width

Read Width Source # 
Instance details

Defined in Language.Fluent.Width

Show Width Source # 
Instance details

Defined in Language.Fluent.Width

Methods

showsPrec :: Int -> Width -> ShowS #

show :: Width -> String #

showList :: [Width] -> ShowS #

Eq Width Source # 
Instance details

Defined in Language.Fluent.Width

Methods

(==) :: Width -> Width -> Bool #

(/=) :: Width -> Width -> Bool #