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 as | Written as | {gold} = 1234567.5, English · German · Russian |
|---|---|---|
int, long, float, double, decimal | A number, grouped and pointed as the language writes numbers, with the places it has | 1,234,567.5 · 1.234.567,5 · 1 234 567,5 |
DateTime, DateTimeOffset | A date, in the player's time zone | Dec 31, 2026 · 31.12.2026 · 31 дек. 2026 г. |
TimeSpan | A length of time, in its two largest units | 2 hr, 5 min · 2 Std., 5 Min. · 2 ч 5 мин |
string | Text, 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.
| Style | For | {x} = | English | German |
|---|---|---|---|---|
0.00, 0.0#, 0 | A number with at least the zeros' places and at most the zeros' and the hashes', rounded half to even | 9.5 | 9.50 | 9,50 |
percent, percent 0.0 | A number as a percent: 0.45 is 45 | 0.45 | 45% | 45 % |
compact | A number short, two significant digits | 1234567 | 1.2M | 1,2 Mio. |
date, date short, date medium, date long, date full | A date; date is medium | Dec 31, 2026 | Dec 31, 2026 | 31.12.2026 |
time, time medium | A time of day; medium has seconds | 15:45:30 | 3:45 PM | 15:45 |
duration | A length of time, its two largest units of days, hours, minutes and seconds; what no style is | 7530 s | 2 hr, 5 min | 2 Std., 5 Min. |
timer | A length of time as a timer | 7530 s | 2:05:30 | 2:05:30 |
relative | A 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 s | 5 minutes ago · yesterday | vor 5 Minuten · gestern |
relative-short | The same with short units | -300 s | 5 min. ago | vor 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 DateTimeFormatNumber 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:
| Digits | What it writes |
|---|---|
| Each Language's | As 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 Own | Each 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-startin 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.
leftandrightin a sheet stay left and right,text-align: lefttoo. For a side that follows the language, write the side the text starts from or ends at, as on the web:
| Logical property | In English | In Arabic |
|---|---|---|
margin-inline-start, margin-inline-end, margin-inline | margin-left, margin-right | margin-right, margin-left |
padding-inline-start, padding-inline-end, padding-inline | padding-left, padding-right | the other way |
inset-inline-start, inset-inline-end, inset-inline | left, right | the other way |
border-inline-start, border-inline-end, border-inline, with -width and -color | border-left, border-right | the other way |
border-start-start-radius, border-start-end-radius, border-end-start-radius, border-end-end-radius | top-left, top-right, bottom-left, bottom-right | top-right, top-left, bottom-right, bottom-left |
text-align: start, text-align: end | left, right | right, 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
- Localization:
Format,FormatNumber,FormatDate,FormatTime,FormatDuration,FormatRelative,RightToLeft. - LocalizedArgument and ArgumentKind: an argument and the kind of value it holds.
- DateLength, DurationStyle, RelativeStyle and NumberDigits.
- GameUi:
Mirror, for interface built in code.
