@quenty/clienttranslator
v14.47.3
Published
Gets local translator for player
Downloads
7,162
Maintainers
Readme
ClientTranslator
Gets local translator for player
Installation
npm install @quenty/clienttranslator --saveWorking on this package
Read these before changing the translation stack. They record design intent that cannot live in the code, because most of this package's shape is driven by engine behavior that is not obvious from reading it:
docs/design.md— why the stack is shaped the way it is: batched localization writes, per-key readiness, the translator fallback chain, re-entrancy rules.docs/engine-behavior.md— verifiedLocalizationTableandTranslatorbehavior the design rests on, and how to verify more of it.
Consumer-facing behavior is documented in
docs/gotchas/localization.md at the repo root.
Usage
Usage is designed to be simple.
Easy-use scenario
- Call Translate(data, "blah") on anything
- Translation is magically replicated to clients and can be saved
- Only one place needed to save the data
Adding localization files
Add files to ReplicatedStorage/i18n. Files will be in string values, and be valid JSON. This allows lookup like this:
{
"key": {
"secondary": {
"node": "My translated value"
}
}
}This will generate an entry like this:
"key.secondary.node" --> My translated valueWhich can be output like this:
ClientTranslator:FormatByKey("key.secondary.node") --> My translated valueAll substitutions and other formats work like Roblox's does.
Pseudo-localize
There exists a pseudo-locale qlp-pls which can be to visualize pseudo-localized text. This can be used to help detect unlocalized text.
API surface
ClientTranslatorFacade:Init()
Initializes a new instance of the ClientTranslatorFacade.
ClientTranslatorFacade:FormatByKey(key, ...)
Works the same way that Roblox's ClientTranslator:FormatByKey functions. However, functions when not online, and also will utilize a pseudo-locale.
