Skip to content

Internationalization ​

ChartSpire ships with en-US (English). Register each additional language once, before creating a ChartSpire instance that uses it.

Registering a Language ​

registerLocale accepts one flat message catalog for the complete widget, including menus, dialogs, chart tooltips, and period labels. Partial catalogs are supported; missing messages fall back to en-US.

typescript
import { ChartSpire, registerLocale } from '@chartspire/ui'

registerLocale('fr-FR', {
  symbol_search: 'Recherche de symbole',
  setting: 'Paramètres',
  'Light Theme 1': 'Thème Clair 1',
  'Dark Theme': 'Thème Sombre',
  'chart.tooltip.time': 'Temps: ',
  'chart.tooltip.open': 'Ouvert: ',
  'chart.tooltip.high': 'Haut: ',
  'chart.tooltip.low': 'Bas: ',
  'chart.tooltip.close': 'Fermer: ',
  'chart.tooltip.volume': 'Volume: ',
  'chart.period.hour': 'H',
  'chart.period.day': 'J',
  // ...more keys from the Locale Keys catalog
})

const chartspire = new ChartSpire({
  container: '#chart',
  locale: 'fr-FR',
  // ...other options
})

See the full Locale Keys catalog for every supported key and its English default.

Calling registerLocale again merges the supplied messages. It replaces both the former single-key update API and separate UI locale loader:

typescript
registerLocale('fr-FR', {
  setting: 'Préférences',
  symbol_search: 'Recherche de ticker',
})

Register locale changes before creating widgets. Registration updates the shared message definition; setLocale controls the active language of a widget instance.

Setting the Active Language ​

typescript
const chartspire = new ChartSpire({
  container: '#chart',
  locale: 'en-US',
  // ...other options
})

// The locale must be registered first.
chartspire.setLocale('fr-FR')

setLocale updates every current and future chart, menu, dialog, replay control, and timezone label inside that ChartSpire instance. Other ChartSpire instances on the page are unaffected.

Custom Candle Tooltip Templates ​

ChartSpire maps the documented chart.tooltip.* keys to the built-in candle tooltip. A custom candle.tooltip.legend.template should provide literal display titles because the underlying chart locale registry is not part of the public ChartSpire API.