Skip to Content

Customization

Translate embed content

Show metric names, chart labels and data values in your viewer's language.

Set two props on <dbn-dashboard> or <dbn-metric> (webcomponents.ts:366-367, 469-470):

PropTypeWhat it does
languagestringThe language key to use, for example fr
translation-dictionaryJSONYour translations, by source text and language key

Steps

  1. Write the dictionary. Each key is text as the embed shows it. Each value maps a language key to the translation.

    {
      "Total Sales": { "en": "Total Sales", "fr": "Ventes totales" },
      "Category": { "en": "Category", "fr": "Catégorie" },
      "No data to show.": { "fr": "Aucune donnée à afficher." }
    }
  2. Add both props to the element.

    <dbn-dashboard
      token="GUEST_TOKEN"
      dashboard-id="DASHBOARD_ID"
      language="fr"
      translation-dictionary='{"Total Sales":{"fr":"Ventes totales"},"Category":{"fr":"Catégorie"}}'
    ></dbn-dashboard>

    In JS, set the dictionary as an object: el.translationDictionary = dictionary.

The embed shows the translated text. To switch language, change language and keep the same dictionary.

What the embed translates

The dictionary applies to the content of each metric:

  • Metric name, description, long description and footnote (hooks/useMetricCard.ts:4218-4255).
  • Column names and data values in charts, tables and single values (utils/getChartOptions.ts:476-500, 825-910, components/Table/index.tsx:600-610).
  • Axis names, series names and legends (utils/getChartOptions.ts:825-910).
  • Card messages, such as the empty card text and custom-messages (v2/surfaces/MetricCard/states/shared.ts:27-37).

The dictionary does not change filter labels or the embed’s own buttons and menus.

language is any key you use in the dictionary. Databrain has no fixed list. fr and fr-FR are different keys.

The dictionary changes text only. It does not change number or date formats, or currency. For time zones, use the guest token’s params.timezone.

If something goes wrong

  • Nothing is translated. Set both language and translation-dictionary. The embed ignores the dictionary when either one is missing.
  • Part of a word changes. A key also matches inside longer text. See how translation matching works.

Use a fiscal calendar

calendar-type="ind" makes date presets use a fiscal year from 1 April to 31 March. The default is default, a calendar year (publicTypes.ts:56, helpers/generateTimeRangeWhereClauseOld.ts:92-102).

Next, learn how translation matching works.