Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs/en-US/next/api/strings/get-gt.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,26 @@ export default async function TranslateGreeting() {
```
Note: "Alice" will not be translated to the user's preferred language because it is a variable.

### Translating page metadata [#metadata]
Use `getGT` inside Next.js `generateMetadata` to translate page titles, descriptions, and Open Graph tags.

```javascript copy
import { getGT } from 'gt-next/server';
import { Metadata } from 'next';

export async function generateMetadata(): Promise<Metadata> {
const gt = await getGT();
return {
title: gt('My App'),
description: gt('A fast, modern web application'),
openGraph: {
title: gt('My App'),
description: gt('A fast, modern web application'),
},
};
}
```

### Using ICU message format

`gt-next` supports ICU message format, which allows you to also format your variables.
Expand Down
2 changes: 2 additions & 0 deletions docs/en-US/next/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -329,5 +329,7 @@ That's it — your app is now multilingual. 🎉
- [**`<T>` Component Guide**](/docs/next/guides/t) — Learn about variables, plurals, and advanced translation patterns
- [**String Translation Guide**](/docs/next/guides/strings) — Deep dive into `useGT` and `getGT`
- [**Variable Components**](/docs/next/guides/variables) — Handle dynamic content with `<Var>`, `<Num>`, `<Currency>`, and `<DateTime>`
- [**Pluralization**](/docs/next/api/components/plural) — Handle plural forms with the `<Plural>` component
- [**Translating Page Metadata**](/docs/next/api/strings/get-gt#metadata) — Translate titles, descriptions, and OG tags with `getGT`
- [**Deploying to Production**](/docs/next/tutorials/quickdeploy) — CI/CD setup, caching, and performance optimization
- [**Shared Strings**](/docs/next/guides/shared-strings) — Translate text in arrays, config objects, and shared data with `msg()`
1 change: 1 addition & 0 deletions docs/en-US/react/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -310,5 +310,6 @@ That's it — your app is now multilingual. 🎉
- [**`<T>` Component Guide**](/docs/react/guides/t) — Learn about variables, plurals, and advanced translation patterns
- [**String Translation Guide**](/docs/react/guides/strings) — Deep dive into `useGT`
- [**Variable Components**](/docs/react/guides/variables) — Handle dynamic content with `<Var>`, `<Num>`, `<Currency>`, and `<DateTime>`
- [**Pluralization**](/docs/react/api/components/plural) — Handle plural forms with the `<Plural>` component
- [**Deploying to Production**](/docs/react/tutorials/quickdeploy) — CI/CD setup, caching, and performance optimization
- [**Shared Strings**](/docs/react/guides/shared-strings) — Translate text in arrays, config objects, and shared data with `msg()`
Loading