| Copyright | (c) 2026 Institute for Digital Autonomy |
|---|---|
| License | EUPL-1.2 |
| Maintainer | IDA |
| Safe Haskell | Trustworthy |
| Language | Haskell2010 |
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
Localetypeclass which supplies locale-specific operations - the
Bundletype which combinesLocales with parsedResources - the
Translatetypeclass which translates messages from aBundle
This library does not provide any production-ready instances of Locale.
Applications should instead use a dedicated backend for full localisation support, such as:
- fluent-icu, backed by text-icu
- miso-fluent,
backed by the browser's
IntlAPI
For quick evaluation or basic English translation, this library includes an example
English locale. It implements a small subset of English rules and is
not a replacement for a full-featured backend.
Synopsis
- data Identifier
- data Resource
- bundle :: NonEmpty locale -> [Resource] -> Bundle locale
- data Bundle locale = Bundle {}
- data Override
- = UseIsolating Bool
- | WithFunction Identifier ([Pattern] -> HashMap Identifier Value -> Either String Pattern)
- module Language.Fluent.Locale
- numberOptions :: NumberOptions
- data CurrencyDisplay
- data NumberOptions = NumberOptions {}
- data Style
- parseResource :: Text -> Either String Resource
- parseResourceLenient :: Text -> Resource
- newtype Pattern = Pattern (NonEmpty PatternElement)
- data PatternElement
- module Language.Fluent.Plural
- fluent :: QuasiQuoter
- messageIdentifiers :: FilePath -> DecsQ
- timeOptions :: TimeOptions
- data Digits
- data TimeOptions = TimeOptions {}
- module Language.Fluent.Translate
- class ToValue v where
- data Value
- data Width
Documentation
data Identifier #
Instances
| Show Identifier # | |
Defined in Language.Fluent.AST Methods showsPrec :: Int -> Identifier -> ShowS # show :: Identifier -> String # showList :: [Identifier] -> ShowS # | |
| Eq Identifier # | |
Defined in Language.Fluent.AST | |
| Ord Identifier # | |
Defined in Language.Fluent.AST Methods compare :: Identifier -> Identifier -> Ordering # (<) :: Identifier -> Identifier -> Bool # (<=) :: Identifier -> Identifier -> Bool # (>) :: Identifier -> Identifier -> Bool # (>=) :: Identifier -> Identifier -> Bool # max :: Identifier -> Identifier -> Identifier # min :: Identifier -> Identifier -> Identifier # | |
| Hashable Identifier # | |
Defined in Language.Fluent.AST | |
| Lift Identifier # | |
Defined in Language.Fluent.TH Methods lift :: Quote m => Identifier -> m Exp # liftTyped :: forall (m :: Type -> Type). Quote m => Identifier -> Code m Identifier # | |
A collection of Fluent resources and the configuration needed to resolve and format messages for a locale.
Constructors
| Bundle | |
Fields
| |
A change to a Bundle.
Constructors
| UseIsolating Bool | Whether to use isolation marks around placeables. |
| WithFunction Identifier ([Pattern] -> HashMap Identifier Value -> Either String Pattern) | Add a function, shadowing the builtin of the same name. |
module Language.Fluent.Locale
data CurrencyDisplay Source #
How a Currency is displayed.
Instances
data NumberOptions Source #
Constructors
| NumberOptions | |
Fields | |
Instances
| Show NumberOptions Source # | |
Defined in Language.Fluent.Number Methods showsPrec :: Int -> NumberOptions -> ShowS # show :: NumberOptions -> String # showList :: [NumberOptions] -> ShowS # | |
| Eq NumberOptions Source # | |
Defined in Language.Fluent.Number Methods (==) :: NumberOptions -> NumberOptions -> Bool # (/=) :: NumberOptions -> NumberOptions -> Bool # | |
What a number denotes, which determines how it is formatted.
parseResourceLenient :: Text -> Resource #
Constructors
| Pattern (NonEmpty PatternElement) |
data PatternElement Source #
A single piece of a Pattern.
Constructors
| Value Value | A value, ready to be formatted. |
| Isolated Pattern | A sequence of values surrounded by isolation marks (FSI, PDI). |
Instances
| IsString PatternElement Source # | |
Defined in Language.Fluent.Pattern Methods fromString :: String -> PatternElement # | |
| Show PatternElement Source # | |
Defined in Language.Fluent.Pattern Methods showsPrec :: Int -> PatternElement -> ShowS # show :: PatternElement -> String # showList :: [PatternElement] -> ShowS # | |
module Language.Fluent.Plural
fluent :: QuasiQuoter #
messageIdentifiers :: FilePath -> DecsQ #
How many digits a date or time field takes, e.g. the ninth month is
9 when Numeric and 09 when TwoDigit.
data TimeOptions Source #
Constructors
| TimeOptions | |
Instances
| Show TimeOptions Source # | |
Defined in Language.Fluent.Time Methods showsPrec :: Int -> TimeOptions -> ShowS # show :: TimeOptions -> String # showList :: [TimeOptions] -> ShowS # | |
| Eq TimeOptions Source # | |
Defined in Language.Fluent.Time | |
module Language.Fluent.Translate
class ToValue v where Source #
Types usable as arguments in Fluent message formatting.
Instances
The concrete representation of a Fluent value, along with any formatting options.