Skip to content

aivi.i18n

Internationalisation marker helpers for user-facing text.

This module is deliberately small today:

  • tr returns the text you pass in unchanged
  • trn chooses the singular text when the count is 1, otherwise the plural text

That still lets you mark strings for translation now, even before a real locale/catalog runtime is wired in.

Import

aivi
use aivi.i18n (
    tr
    trn
    translate
    translatePlural
)

Overview

FunctionTypeDescription
trText -> TextMark one string for translation
trnText -> Text -> Int -> TextChoose singular or plural text
translateText -> TextLonger alias for tr
translatePluralText -> Text -> Int -> TextLonger alias for trn

tr

aivi
tr : Text -> Text

Mark a single string for translation.

aivi
use aivi.i18n (tr)

value saveLabel : Text =
    tr "Save"

trn

aivi
trn : Text -> Text -> Int -> Text

Choose between a singular and plural form.

aivi
use aivi.i18n (trn)

type Int -> Text
func fileCountLabel = count =>
    trn "1 file" "{count} files" count

translate

aivi
translate : Text -> Text

Friendly alias for tr.

translatePlural

aivi
translatePlural : Text -> Text -> Int -> Text

Friendly alias for trn.

Example

aivi
use aivi.i18n (
    tr
    trn
)

value title : Text = tr "Downloads"

type Int -> Text
func itemLabel = count =>
    trn "1 item" "{count} items" count

AIVI Language Manual