@ -22,14 +22,40 @@ Grafana uses the [i18next](https://www.i18next.com/) framework for managing tran
```jsx
import { Trans } from 'app/core/internationalization';
const SearchTitle = ({ term }) => <Transi18nKey="search-page.results-title">Results for {{ term }}</Trans>;
```
Prefer using `<Trans />` for JSX children, and `t()` for props and other JavaScript usage.
There may be cases where you need to interpolate variables inside other components in the translation.
If the nested component is displaying the variable only (e.g. to add emphasis or color), the best solution is to create a new wrapping component:
```jsx
import { Trans } from 'app/core/internationalization';
import { Text } from '@grafana/ui';
const SearchTerm = ({ term }) => <Textcolor="success">{term}</Text>;
const SearchTitle = ({ term }) => (
<Transi18nKey="search-page.results-title">
Results for <em>{{ term }}</em>
Results for <SearchTermterm={term}/>
</Trans>
);
```
Prefer using `<Trans />` for JSX children, and `t()` for props and other JavaScript usage.
However there are also cases where the nested component might be displaying additional text which also needs to be translated. In this case, you can use the `values` prop to explicitly pass variables to the translation, and reference them as templated strings in the markup. For example:
```jsx
import { Trans } from 'app/core/internationalization';