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 committed Mar 21, 2024
1 parent eaac14f commit 335c039
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 335c039

Please sign in to comment.