Skip to content

Widget.t

Widget.t(key, variables?): string

Widget.t returns a text from strings in manifest.json in the chosen language. {name} is replaced by variables.name.

{
"strings": {
"es": { "follow": "¡Nuevo follow de {name}!" },
"en": { "follow": "New follower: {name}!" }
}
}
Widget.dom.text(app, Widget.t("follow", { name: user }));

With more than one language in strings, the “Texts” menu lets the viewer choose which one the widget uses. Write the visible texts there and not inside the code: that way they are translated without touching script.js.

The chosen language ("es", "en"…), one of those in strings.

The chosen design from designs in manifest.json; it is also left in <html data-design>, to change the look from CSS.