lxn
v1.0.4
Published
An lxn implementation for JavaScript
Downloads
8
Readme
lxn-js
lxn-go
is an lxn client library for the Javascript programming language.
Translating Text
To translate text, a catalog has to be loaded:
function readCatalog(buf: BufferSource): Translator
This function reads a binary catalog from buf
, which could either be an ArrayBuffer
or an ArrayBufferView
, and returns its translator function. Once a translator function of type
type Translator = (key: string, ctx: Context) => string;
is obtained, it can be used to convert a key and a context into a message. The key specifies the message key within the catalog preceded by its section, i.e. section.message-key
(or simply message-key
if the message has no section). The context contains all the necessary variables to render this message correctly. For each variable in the catalog there has to be a value of the corresponding type.