gipity add i18n makes a web app multi-language: a language picker, localStorage persistence, automatic RTL (<html dir>), and plural/translation lookup. It installs into src/packages/i18n/.

Install, then route copy through t()

Templates don't ship a copy table or an @gipity/i18n import, so install the kit first:

gipity add i18n

The install:

Then move the app's user-facing text into strings.js and replace hard-coded copy with t('key'):

// src/js/strings.js - the one place copy lives (English is the base)
export const strings = {
  welcome: 'Welcome',
  greeting: 'Hello, {name}!',
  items_one: '{count} item',
  items_other: '{count} items',
};
import { t, tn, getLang } from '@gipity/i18n';

el.textContent = t('welcome');
el.textContent = t('greeting', { name: 'Sam' });   // "Hello, Sam!" - {placeholder} interpolation
el.textContent = tn('items', cart.length);          // plural-aware: items_one / items_other

A missing key renders as the key itself, never blank.

Add languages

"translate strings to Spanish and Japanese"

Translations land in src/packages/i18n/translations.js, mirroring the keys in strings.js. English stays the base in strings.js and never appears there.

export const translations = {
  es: { welcome: 'Bienvenido', items_one: '{count} artículo', items_other: '{count} artículos' },
  ja: { welcome: 'ようこそ', items_other: '{count}個' },
};

The runtime API

import { t, tn, getLang, setLang, availableLangs, isRtl } from '@gipity/i18n';
setLang('es');          // switch + persist; getLang()/<html lang|dir>/listeners all updated synchronously
availableLangs();       // ['en', ...languages present in translations.js]

The picker is a <select> auto-mounted to <body> once at least one translation exists - nothing to wire. Style it via the .lang-picker class (web-simple's styles.css already positions it top-right). To place it yourself, mountLangPicker({ getLang, setLang, availableLangs }, parentEl).

Re-rendering on language change

setLang() (and the picker) fires an i18n:changed event on document, synchronously - by the time it returns, getLang() and <html lang>/<html dir> are already updated. Re-pull your text in a render() wired to it (add this to main.js yourself; the templates don't include it):

function render() { /* your t('key') → DOM assignments */ }
document.addEventListener('i18n:changed', render);
render();

Notes