<T>
Using the <T> tag to translate your components
<T>
is the translation tag in gt-next
. Children of <T>
will be translated into your configured languages.
To create translations, run the gt-update
CLI tool before you build your app.
If it is being used in a client component, <T>
must be able to access the context from a <GTProvider>
.
It requires two props:
id
, which is a unique string representing the contentchildren
, which is the content to translate
For example, the following code would translate the content "Hello, world"
with the id "greeting"
.
The above would display "Hello, world"
in the English version of the app, and "Hola mundo"
in the Spanish version.
The <T>
component can also contain JSX, like:
Text must be passed directly as a child of <T>
to be translated.
<T>
uses our cloud services to create and cache translations. If a translation is unavailable, <T>
will default to displaying the content in your default locale (defaultLocale
), usually English.
On-demand translation
Testing <T>
in server components is easy, just change your browser language and reload the page.
Translations will be created on-demand and load in within a few seconds.