# How do I format numbers, dates and currencies for each locale?

47.1 s · Narrator: Frederick Surrey

Wrap each value in the component for its type: Num for numbers, Currency for money, DateTime for dates and RelativeTime for relative time. Each formats the value for the active locale with JavaScript's Intl API, locally, without sending it to a translation service.

| Time | Voice | Line | On screen |
| --- | --- | --- | --- |
| 0:00.88 | Narrator | In Munich, your page writes its total with a decimal point and no euro sign. | A page draws in the middle of the frame. On "Munich" the language code `de` appears over its top right corner, and on "page" its two sentences rise: "12500 downloads are complete." and "Your total is 12450.75.", with the values as the code holds them. On "total" the total sentence turns blue, the heading "A decimal point and no euro sign" rises on "a", and on "sign" a white box draws around the total. |
| 0:06.00 | Narrator | The code prints each value as it is, unformatted for any locale. | On "The" the page slides to the right, and on "code" a code panel opens with `Downloads.tsx`, a paragraph that renders `{count} downloads are complete.`, over `Total.tsx`, which renders `Your total is {total}.`. On "value" the page's blue and its box go, and `{count}` and `{total}` turn blue. On "is" a line joins the `{total}` row to the page's total. |
| 0:10.76 | Narrator | General Translation formats values for each locale with Num, Currency and DateTime. | The answer card cuts in on "General": the answer alone rises as it is spoken, in two lines, "General Translation formats values for each locale" then "with <Num>, <Currency> and <DateTime>", and the General Translation mark sits small in the lower left corner. |
| 0:16.80 | Narrator | After npx gt init, Num groups the count's digits, and Currency formats the total without converting it. | The heading "Format the count with <Num>". The code panel opens again with a terminal over `Downloads.tsx`, and `npx gt init` is typed as it is spoken. On "init" a panel opens on the right, labelled `{count}`, that lists what the paragraph shows in each language: en, es, ja and de, each 12500. On "Num" `import { T, Num } from 'gt-next';` opens at the top; on "groups" `{count}` becomes `<Num>{count}</Num>`, and the panel's label becomes `<Num>{count}</Num>` and its values 12,500 for en, 12.500 for es, 12,500 for ja and 12.500 for de; on "digits" `<T>` and `</T>` open around the paragraph. A blue bar marks each changed line. On "Currency" the code panel cuts to `Total.tsx`, where `<Currency currency="EUR">` wraps `{total}`, and the panel beside it changes to `<Currency currency="EUR">`, with the amount in each language's format. On "total" `currency="EUR"` turns blue, and on "converting" a white box draws around the four amounts, the same 12,450.75 euros in every row. |
| 0:24.54 | Narrator | The DateTime component formats dates, and the RelativeTime component writes phrases such as three days ago. | The heading "Format dates with DateTime". The code panel shows `Published.tsx`: inside `<T>`, "Published" followed by `<DateTime options={{ timeZone: 'UTC' }}>{publishedAt}</DateTime>`. On "dates" the panel beside it changes to `<DateTime>`: 3/14/2026 for en, 14/3/2026 for es, 2026/3/14 for ja and 14.3.2026 for de. On "Relative" the code panel changes to `Activity.tsx`, `<RelativeTime value={-3} unit="day" />`, and on "writes" the panel beside it changes to `<RelativeTime>`, with the phrase for three days ago in each of the four languages. On "three" a white box draws around the four phrases. |
| 0:31.24 | Narrator | Run npx gt translate, and the words are translated into Spanish, Japanese and German. | The heading "Run npx gt translate". The code panel shows `gt.config.json`, with `"defaultLocale": "en"`, `"locales": ["es", "ja", "de"]` and the output path `public/_gt/[locale].json`, over a terminal where `npx gt translate` is typed. On "words" the page draws again on the right in place of the panel, in English with the code `en` and its values formatted: "12,500 downloads are complete." and "Your total is €12,450.75.". It switches to Spanish on "Spanish", to Japanese on "Japanese" and to German on "German", its sentences translated and its values formatted for each language. |
| 0:37.54 | Narrator | In Munich, the total and the count now follow German conventions. | The code panel goes, and on "Munich" the page slides back to the middle of the frame, in German. On "total" the German total turns blue, in the place where the unformatted total turned blue at the start, and it stays blue to the end. On "conventions" white boxes draw around the two sentences. |
| 0:41.88 | No voice |  | The end card: the General Translation logo with generaltranslation.com/docs/react/guides/formatting-variables under it, held to the last frame while the music ends on a held chord. |

Times are where each line starts in the final, read from the film's own audio.
