battlecore::lang
The langmodule shows a game's text in the player's language and wording. Include its declarations with include "./battlecore/lang.bst";.
Each tagger has its own language (English, German, French or Spanish so far) and its own wording. The wording is standard, or family, which says "tag" and "out" where standard says "kill" and "dead". The player chooses both in the tagger's Settings menu or in the app.
A game's wording setting can choose the wording for every player while the game runs. Its value is player (each tagger's own, the default), standard or family. The language is never chosen for other players: each tagger shows its own.
How a message is found
You write the English, and the English is the message's name. The tagger looks for a translation in this order:
- the game's own wording (for example the game's Family words);
- the game's own language pack;
- the tagger's core wording;
- the tagger's core language pack;
- the English you wrote.
So a message with no translation still shows, in English. A broken translation leaves a placeholder unfilled; it never stops the game.
Write the English as a string in the call itself. The translation tools find a game's messages by reading its script, so text built up in a variable is never translated.
t
Returns the text in the tagger's language and wording. Placeholders are named, such as {flag}, and filled from values.
native string battlecore::lang.t (string text, object values = {});Write whole sentences, with placeholders for the parts that change. A translation may need to move the placeholder. It cannot fix a sentence glued together from pieces.
// Not this: the pieces cannot be reordered in another language.
refuse("Capture flag " + missing + " first", "failed.wav");
// This: one message, with a placeholder.
refuse(battlecore::lang.t("Capture flag {flag} first", {"flag": missing}), "failed.wav");tc
The same as t, for English that means two different things. The context keeps them apart, so each can be translated in its own way. For example, a short heading on the in-game screen and the same word in a sentence.
native string battlecore::lang.tc (string context, string text, object values = {});battlecore::screens.setText("prompt", battlecore::lang.tc("hud", "SHOT"));tn
A message with a count. Give the English for one and for more than one; the tagger picks the form the language uses for n, and fills {n} with it. Some languages have more than two forms, and the translation carries all of them.
native string battlecore::lang.tn (string one, string other, int n, object values = {});battlecore::screens.setText("prompt", battlecore::lang.tn("{n} flag left", "{n} flags left", flagsLeft));getLanguage and getWording
The tagger's language code ("en", "fr") and the wording on its screen now ("standard", "family"). During a game that sets a wording, getWording returns the game's.
native string battlecore::lang.getLanguage ();
native string battlecore::lang.getWording ();Text sent to other taggers
Translate text on the tagger that shows it, never before it is sent. Players in the same game can have different languages. Send a number or a name with net, and let each tagger turn it into its own words.
The config's text
Each setting's label, help, unit and choice labels in a game's configare messages too, and so is the game's name. The app asks for them in the phone's language, so a player sees a game's settings in their own language.
Translating a game
The shipped games' translations are kept beside the firmware and built into its filesystem: one pack per game and language, in /lang/<gameId>/. A game you upload yourself has no pack of its own yet. A message the tagger already knows, such as "Pull trigger to respawn!", which the shipped games share, is translated. The rest shows in English. Packs carried with a user game are planned.