Internationalization

WebPivotTable supports internationalization (i18n). End users can switch languages at runtime without reloading the page.

Bundled Languages

The following locales ship with WebPivotTable and are available out of the box:

Locale code Language
en English
zh-CN Simplified Chinese
de German
es Spanish
fr French
it Italian
pt Portuguese
tr-TR Turkish

Locale JSON files are located in the public/locales/ directory:

public/
  locales/
    de.json
    en.json
    es.json
    fr.json
    it.json
    pt.json
    tr-TR.json
    zh-CN.json

How Locale Files Are Resolved

WebPivotTable resolves locale files using the following priority order:

  1. localeBaseUrl — if set, this explicit URL is used directly.
  2. localeFilePath — a legacy option; if set, it is used as the base path.
  3. localeDeploymentMode — determines the fallback:
    • 'cdn' (default) — loads from https://cdn.webpivottable.com/wpt/v<version>/locales
    • 'self-host' — loads from /locales on your own server.

You can also supply a custom CDN URL via localeCdnBaseUrl.

See Options → Locale for full details on each setting.

Setting the Default Locale

The default locale is 'en'. Override it at startup via the locale option:

const wpt = document.querySelector('web-pivot-table');
wpt.setOptions({ locale: 'zh-CN' });

Or pass it as an attribute:

<web-pivot-table options='{"locale":"zh-CN"}'></web-pivot-table>

Customising Available Locales

The language switcher in the header shows every entry in the availableLocales array. You can override it to expose only the languages you need:

wpt.setOptions({
  availableLocales: [
    { value: 'en',    abbr: 'EN', label: 'Lbl_English',  attach: ' ( english ) ' },
    { value: 'zh-CN', abbr: 'CN', label: 'Lbl_Chinese',  attach: ' ( 中文 ) ' },
  ],
});

See Options → availableLocales for the full default list and property reference.

Adding Your Own Language

To add a language that is not bundled:

  1. Copy an existing locale file (e.g. en.json) and translate every value.
  2. Save it as <locale-code>.json in the same directory (e.g. ja.json).
  3. Add the locale to availableLocales so it appears in the language switcher.
wpt.setOptions({
  availableLocales: [
    // ... existing locales ...
    { value: 'ja', abbr: 'JA', label: 'Lbl_Japanese', attach: ' ( 日本語 ) ' },
  ],
});

WebPivotTable will fetch the JSON file automatically when the user selects that language.