Skip to content

Commit

Permalink
example usage of useTranslation inside generateMetadata (#1199)
Browse files Browse the repository at this point in the history
* added second-page-title to locales/ca/common.json

* added second-page-title to locales/es/common.json

* added second-page-title to locales/en/common.json

* added generateMetadata with usage of useTranslation
  • Loading branch information
huseyinonalcom authored and aralroca committed Mar 21, 2024
1 parent 7445cf2 commit 8cfe3ab
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/with-app-directory/locales/ca/common.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"title": "Llibreria next-translate",
"second-page": "Segona <0>pàgina</0>",
"second-page-title": "Títol Segona Pàgina",
"loading": "Carregant...",
"layout-title": "Títol de la pàgina (del layout)"
}
1 change: 1 addition & 0 deletions examples/with-app-directory/locales/en/common.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"title": "next-translate library",
"second-page": "Second <0>page</0>",
"second-page-title": "Second Page Title",
"loading": "Loading...",
"layout-title": "Layout title"
}
1 change: 1 addition & 0 deletions examples/with-app-directory/locales/es/common.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"title": "Librería next-translate",
"second-page": "Segunda <0>página</0>",
"second-page-title": "Título Segunda Página",
"loading": "Cargando...",
"layout-title": "Título de la página (del layout)"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import Link from 'next/link'
import useTranslation from 'next-translate/useTranslation'
import Trans from 'next-translate/Trans'
import { Metadata } from "next";

export function generateMetadata(): Metadata {
const { t } = useTranslation("common");

return {
title: t`second-page-title`
};
}

export default function Page() {
const { t, lang } = useTranslation('common')
Expand Down

0 comments on commit 8cfe3ab

Please sign in to comment.