Manual

Manual

Numbers, dates and right-to-left

Each language writes numbers, dates and lengths of time its own way, and some languages are read from the right. This page covers how a string's arguments are written in the player's language, the styles a string can ask for, formatting a value in code, which digits a game writes in, and how a game is shown in Arabic, Hebrew, Persian and Urdu.

The formats are Unicode CLDR's, kept in the engine for the 86 languages it knows by name, so a built game writes them the same on every computer and in a browser. A language the engine does not know writes as its shorter code does (pt-BR as pt), and otherwise as English does.

Arguments by their kind

An argument is written by the kind of value code gives it:

Given asWritten as{gold} = 1234567.5, English · German · Russian
int, long, float, double, decimalA number, grouped and pointed as the language writes numbers, with the places it has1,234,567.5 · 1.234.567,5 · 1 234 567,5
DateTime, DateTimeOffsetA date, in the player's time zoneDec 31, 2026 · 31.12.2026 · 31 дек. 2026 г.
TimeSpanA length of time, in its two largest units2 hr, 5 min · 2 Std., 5 Min. · 2 ч 5 мин
stringText, as it is
Label.Text = flow.Localization.Format(Strings.Hud.Gold, ("gold", gold), ("left", nextReward - DateTime.Now));

A number given as text stays as it is written, for a year, a level's code or a player's ID: ("year", "2026"). A number given as a number also picks a string's plural form, as before.

A string is written in the language it was found in: one that falls back to English in a Russian game writes its numbers as English does, so the words and the numbers match.

Styles

A place can ask for a style after a colon: {price:0.00}. Each translation can ask for its own.

StyleFor{x} =EnglishGerman
0.00, 0.0#, 0A number with at least the zeros' places and at most the zeros' and the hashes', rounded half to even9.59.509,50
percent, percent 0.0A number as a percent: 0.45 is 450.4545%45 %
compactA number short, two significant digits12345671.2M1,2 Mio.
date, date short, date medium, date long, date fullA date; date is mediumDec 31, 2026Dec 31, 202631.12.2026
time, time mediumA time of day; medium has seconds15:45:303:45 PM15:45
durationA length of time, its two largest units of days, hours, minutes and seconds; what no style is7530 s2 hr, 5 min2 Std., 5 Min.
timerA length of time as a timer7530 s2:05:302:05:30
relativeA length of time from now, a negative one before now, in the largest unit it is one or more of; the word the language has for the last, this or the next of a unit-300 s · -86400 s5 minutes ago · yesterdayvor 5 Minuten · gestern
relative-shortThe same with short units-300 s5 min. agovor 5 Min.

A style an argument's kind does not have, or one misspelled, leaves the place as it is written, so the mistake shows.

A relative time is written once, when the text is: "5 minutes ago" says so until the game writes it again. Give it a TimeSpan, seenAt - DateTime.Now for a moment.

A price from a store is already written in the player's currency, so there is no currency style.

Formatting in code

Localization writes a value as the language in use does, for text that is no string of a table:

Localization localization = flow.Localization;string gold = localization.FormatNumber(1234567.5);                         // 1,234,567.5string fans = localization.FormatNumber(fans, "compact");                    // 1.2Mstring day = localization.FormatDate(DateTime.Now, DateLength.Long);         // December 31, 2026string time = localization.FormatTime(DateTime.Now);                         // 3:45 PMstring left = localization.FormatDuration(TimeSpan.FromSeconds(330), DurationStyle.Timer); // 5:30string seen = localization.FormatRelative(TimeSpan.FromMinutes(-5));          // 5 minutes agostring next = localization.FormatRelative(reset, RelativeStyle.Short);         // in 3 hr., from a DateTime

FormatNumber throws for a style a number does not have.

Digits

Edit ▸ Project Settings ▸ Localization ▸ Digits says which digits numbers, dates and times are written in:

DigitsWhat it writes
Each Language'sAs CLDR says each language writes them: Bengali, Persian, Marathi, Burmese and Nepali their own, every other language Latin ones. Arabic is written with Latin digits, as CLDR 49 has it.
Latin (123)Latin digits in every language.
Each Language's OwnEach language's own digits where it has some: Arabic ١٢٣, Hindi १२३, Thai ๑๒๓.

Right-to-left languages

A game shown in Arabic, Hebrew, Persian or Urdu is shown right to left. Language.RightToLeft says whether a language is written so, and Localization.RightToLeft whether the game is shown so now.

  • Every UI document is mirrored. Its elements are laid out from the right: a row's first element is at the right, and a bar fills from the right. Text aligned left is aligned right, and text aligned right is aligned left; centered text stays centered. What you set on an element in the Inspector changes sides too: its margins, paddings, and its left and right position. Its borders and rounded corners stay as drawn, so a shape made of borders, such as a dropdown's arrow, keeps its shape; a border on the side the text starts from is border-inline-start in a stylesheet. A value the game's code sets on an element stays where the code set it.
  • Its top has the class rtl. A stylesheet can keep a part as it was made, or show it otherwise:
.rtl .clock { direction: ltr; }
  • A stylesheet keeps CSS's meaning. left and right in a sheet stay left and right, text-align: left too. For a side that follows the language, write the side the text starts from or ends at, as on the web:
Logical propertyIn EnglishIn Arabic
margin-inline-start, margin-inline-end, margin-inlinemargin-left, margin-rightmargin-right, margin-left
padding-inline-start, padding-inline-end, padding-inlinepadding-left, padding-rightthe other way
inset-inline-start, inset-inline-end, inset-inlineleft, rightthe other way
border-inline-start, border-inline-end, border-inline, with -width and -colorborder-left, border-rightthe other way
border-start-start-radius, border-start-end-radius, border-end-start-radius, border-end-end-radiustop-left, top-right, bottom-left, bottom-righttop-right, top-left, bottom-right, bottom-left
text-align: start, text-align: endleft, rightright, left
.badge { inset-inline-end: 8px; }        /* right in English, left in Arabic */
.icon { margin-inline-end: 10px; }

margin-inline: 4px 8px gives the start 4px and the end 8px; one value gives both. A later rule overrides an earlier one whichever kind it is, as on the web. The engine reads a mirrored document's sheets as their right-to-left twins, menu.rtl.css read from menu.css, so a file of your own named .rtl.css is never read as itself.

  • Text is joined and read from the right wherever it is drawn. Arabic, Hebrew and Persian need a font that has their letters; a localized font gives each language its own.
  • An image that points one way, an arrow, is a localized image with an Arabic file.

Interface a game builds in code, outside any UI document, is mirrored where the game asks: world.Ui.Mirror(root) in C#, or the UiMirror component in Rust, mirrors the node and everything under it as a document is, and gives each back as the language reads left to right again, but what the game's code set on it meanwhile.

Trying it in the editor

The Game panel's language list has, after Pseudo, Pseudo RTL: the game shown right to left with the default language's strings mirrored, as Arabic would be. A part of a document that does not mirror stands out before there is a translation or an Arabic font. Like Pseudo, it is in the editor only and kept on your computer.

In the Scripting API