fluent
Safe HaskellNone
LanguageHaskell2010

Language.Fluent.Locale

Synopsis

Documentation

class Locale l where Source #

A locale, identified by an implementation-defined code (e.g. BCP 47, ISO 639).

Methods

fromCode :: Text -> Maybe l Source #

Parse a locale from its textual code, if recognised.

toCode :: l -> Text Source #

Render a locale back to its textual code.

displayLanguage Source #

Arguments

:: l

The language being named

-> l

The language to render the name in

-> Maybe Text 

Translate the name of one language into another.

localDisplayLanguage :: l -> Maybe Text Source #

A language's own name for itself, e.g. Deutsch for German.

capitalise :: l -> Text -> Text Source #

Capitalise the first character of some text following the locale's casing rules.

pluralCategory :: l -> Scientific -> NumberOptions -> Category Source #

Classify a number into a plural category (e.g. "one", "few", "other"), used to pick the matching translation variant.

formatNumber :: NonEmpty l -> Scientific -> NumberOptions -> Either String Text Source #

Format a number according to locale conventions.

formatTime :: NonEmpty l -> UTCTime -> TimeOptions -> Either String Text Source #

Format a point in time according to locale conventions.

Instances

Instances details
Locale English Source #
fromCode
Accepts any code with language "en", ignoring case:
  • "en", "EN", "en-US", and "en_AU" all yield English.
  • "english" is rejected.
toCode
Always yields "en".
displayLanguage
Always yields "English".
pluralCategory
  • Cardinal: One for an absolute value of exactly 1 with zero fraction digits; Other for all other numbers.
  • Ordinal: One for numbers ending in 1; Two for numbers ending in 2; Few for numbers ending in 3; Other for all other integers, fractions, and values beyond Int.
formatNumber
Uses sign, prefix, digits, and suffix layout.
  • Grouping uses commas by default unless disabled.
  • Percent multiplies by 100 and appends a no-break space and "%".
  • Currency defaults to ISO 4217 fractional digits, e.g., 0 for JPY.
  • Units append a no-break space and abbreviation, pluralizing day, week, month, and year with an "s" unless the category is "one".
formatTime
Renders UTC date and time layouts:
  • Fails if the time zone is anything other than UTC.
  • Joins weekday, date, and time fields with ", ".
  • Numeric months, e.g. "21/08/2026"
  • Full month names, e.g. "21 August 2026"
Instance details

Defined in Language.Fluent.Locale.English