Log inGet started
Package

productionKit.package

README.md

productionKit.text

Every word productionKit shows a player goes through this module, which reads it from the engine's translation catalogs (i18n) in the player's language, with the English as a fallback so a missing key never shows as a raw key.

The kit's own modules call it (catalog names, number words and rates, refusals, prompts, screens and displays). A game rarely needs it directly, but can use it the same way for text of its own:

local Text = require("productionKit.text")
Text.t("productionkit.reasons.missing", { resource = "Wood", need = "2" }, "Not enough {{ resource }}: you need {{ need }} more")
Text.key("lumberMill")   -- "lumber_mill": a catalog-safe key part from an id
Text.townName("main")    -- "Millbrook": the name a player reads for a town id
Text.revision()          -- moves when the language or a catalog changes; include it in cache keys
Text.onChange(function(locale) ... end)
  • Text.t(key, values?, fallback): the text in the player's language with {{ name }} values filled in.
  • Text.live(key, values?, fallback): the same as a live value for a widget, which redraws by itself when the language changes.
  • Text.fill(s, values): fills {{ name }} placeholders in any string.
  • Text.townName(id): the name a player reads for a town id, never the id itself. A catalog key productionkit_ui.town.names.<id> in your world comes first, then the name the game gave the town (setup{ townNames = { main = "Riverside" } }), then the kit's own: main reads "Millbrook" (productionkit_ui.town.default), a player's own town (per-player towns) reads "Your Town" (productionkit_ui.town.own), and any other id is spelled out in words (north_farm reads "North Farm").
  • Text.NS ("productionkit") and Text.UI ("productionkit_ui"): the kit's two catalog namespaces, in productionKit.package/locales/en/.

To translate the kit, add locales/<language>/productionkit.json and productionkit_ui.json to your world with the same keys; to change one word, state its key in your world's locales/en/ catalog.