Skip to main content

Module format

Module format 

Source
Expand description

The message format of translated texts: tr! and enum labels.

A text is plain words with placeholders, a subset of ICU MessageFormat:

  • {name}: the argument as text: text as it is, a number as Bern writes numbers, a labelled enum by its label.
  • {name, plural, one {# episode} other {# episodes}}: the branch for the number’s plural category in the text’s language, or an exact =N; # in a branch is the number.
  • {name, date, EEE, MMM d}: a CalendarDate written with the pattern: y year, M month, MM two-digit month, MMM and MMMM the short and full month name, d and dd the day, EEE and EEEE the short and full weekday; other characters as they are.
  • {name, duration, m:ss}: a number of seconds as h, m and s fields, each doubled for two digits; the largest field written takes what the larger ones would hold.

{{ and }} are literal braces; in a plural branch } always ends the branch, so a branch cannot hold a literal }. The names of weekdays and months come from date_names, in every language Bern’s runtimes speak.

Enums§

Arg
A value a text shows.
Piece
One part of a parsed text.
Use
How a text uses one of its arguments.

Constants§

CALENDAR_DATE
The name of the framework type of calendar dates.

Functions§

calendar_date_def
The record of a calendar date: year, month 1–12, day 1–31.
date_names
The names of weekdays (from Monday) and months, short and full, in the languages Bern’s runtimes speak, as framework texts: bern.date.weekday.1 … .7, bern.date.weekday_long.N, bern.date.month.1 … .12, bern.date.month_long.N.
format
Write a text in language with its arguments. name(key) gives the framework texts for month and weekday names.
format_date
Write a date with a checked pattern; name(key) is a framework text.
format_duration
Write a number of seconds with a checked pattern.
missing_plurals
Plural branches a text in language lacks: each category the language uses needs one, so every number has its form.
parse
Parse a text into its pieces.
plural_categories
The plural categories a language’s numbers fall into: Chinese, Japanese and Korean use one form for every number; the languages Bern speaks otherwise tell one apart from the rest.
plural_category
The plural category of number in language.
uses
The arguments a text uses, in order of first use, with how each is used. An argument used two ways is listed with each.
weekday
The day of the week of a date, 0 for Monday.