refactor: update localization handling in metadata generation

- Replaced `pageTranslations` with `pt` for improved clarity in localization across multiple pages including About, Changelog, Contact, Waitlist, Blog, Pricing, and Auth pages.
- Enhanced maintainability by standardizing the variable naming for translation functions.
This commit is contained in:
javayhu 2025-03-16 15:06:42 +08:00
parent 635346bff6
commit 6569e5c3df
11 changed files with 28 additions and 28 deletions

View File

@ -16,11 +16,11 @@ export async function generateMetadata({
}): Promise<Metadata | undefined> {
const {locale} = await params;
const t = await getTranslations({locale, namespace: 'Metadata'});
const pageTranslations = await getTranslations({locale, namespace: 'AboutPage'});
const pt = await getTranslations({locale, namespace: 'AboutPage'});
return constructMetadata({
title: pageTranslations('title') + ' | ' + t('title'),
description: pageTranslations('description'),
title: pt('title') + ' | ' + t('title'),
description: pt('description'),
canonicalUrl: `${getBaseUrlWithLocale(locale)}/about`,
});
}

View File

@ -17,11 +17,11 @@ export async function generateMetadata({
}): Promise<Metadata | undefined> {
const {locale} = await params;
const t = await getTranslations({locale, namespace: 'Metadata'});
const pageTranslations = await getTranslations({locale, namespace: 'ChangelogPage'});
const pt = await getTranslations({locale, namespace: 'ChangelogPage'});
return constructMetadata({
title: pageTranslations('title') + ' | ' + t('title'),
description: pageTranslations('description'),
title: pt('title') + ' | ' + t('title'),
description: pt('description'),
canonicalUrl: `${getBaseUrlWithLocale(locale)}/changelog`,
});
}

View File

@ -12,11 +12,11 @@ export async function generateMetadata({
}): Promise<Metadata | undefined> {
const { locale } = await params;
const t = await getTranslations({ locale, namespace: 'Metadata' });
const pageTranslations = await getTranslations({ locale, namespace: 'ContactPage' });
const pt = await getTranslations({ locale, namespace: 'ContactPage' });
return constructMetadata({
title: pageTranslations('title') + ' | ' + t('title'),
description: pageTranslations('description'),
title: pt('title') + ' | ' + t('title'),
description: pt('description'),
canonicalUrl: `${getBaseUrlWithLocale(locale)}/contact`,
});
}

View File

@ -12,10 +12,10 @@ export async function generateMetadata({
}): Promise<Metadata | undefined> {
const {locale} = await params;
const t = await getTranslations({locale, namespace: 'Metadata'});
const pageTranslations = await getTranslations({locale, namespace: 'WaitlistPage'});
const pt = await getTranslations({locale, namespace: 'WaitlistPage'});
return constructMetadata({
title: pageTranslations('title') + ' | ' + t('title'),
description: pageTranslations('description'),
title: pt('title') + ' | ' + t('title'),
description: pt('description'),
canonicalUrl: `${getBaseUrlWithLocale(locale)}/waitlist`,
});
}

View File

@ -17,10 +17,10 @@ export async function generateMetadata({
}): Promise<Metadata | undefined> {
const {locale} = await params;
const t = await getTranslations({locale, namespace: 'Metadata'});
const pageTranslations = await getTranslations({locale, namespace: 'BlogPage'});
const pt = await getTranslations({locale, namespace: 'BlogPage'});
return constructMetadata({
title: pageTranslations('title') + ' | ' + t('title'),
description: pageTranslations('description'),
title: pt('title') + ' | ' + t('title'),
description: pt('description'),
canonicalUrl: `${getBaseUrlWithLocale(locale)}/blog`,
});
}

View File

@ -15,10 +15,10 @@ export async function generateMetadata({
}): Promise<Metadata | undefined> {
const {locale} = await params;
const t = await getTranslations({locale, namespace: 'Metadata'});
const pageTranslations = await getTranslations({locale, namespace: 'PricingPage'});
const pt = await getTranslations({locale, namespace: 'PricingPage'});
return constructMetadata({
title: pageTranslations('title') + ' | ' + t('title'),
description: pageTranslations('description'),
title: pt('title') + ' | ' + t('title'),
description: pt('description'),
canonicalUrl: `${getBaseUrlWithLocale(locale)}/pricing`,
});
}

View File

@ -12,10 +12,10 @@ export async function generateMetadata({
}): Promise<Metadata | undefined> {
const {locale} = await params;
const t = await getTranslations({locale, namespace: 'Metadata'});
const pageTranslations = await getTranslations({locale, namespace: 'AuthPage.error'});
const pt = await getTranslations({locale, namespace: 'AuthPage.error'});
return constructMetadata({
title: pageTranslations('title') + ' | ' + t('title'),
title: pt('title') + ' | ' + t('title'),
description: t('description'),
canonicalUrl: `${getBaseUrlWithLocale(locale)}/auth/error`,
});

View File

@ -12,10 +12,10 @@ export async function generateMetadata({
}): Promise<Metadata | undefined> {
const {locale} = await params;
const t = await getTranslations({locale, namespace: 'Metadata'});
const pageTranslations = await getTranslations({locale, namespace: 'AuthPage.forgotPassword'});
const pt = await getTranslations({locale, namespace: 'AuthPage.forgotPassword'});
return constructMetadata({
title: pageTranslations('title') + ' | ' + t('title'),
title: pt('title') + ' | ' + t('title'),
description: t('description'),
canonicalUrl: `${getBaseUrlWithLocale(locale)}/auth/forgot-password`,
});

View File

@ -14,10 +14,10 @@ export async function generateMetadata({
}): Promise<Metadata | undefined> {
const {locale} = await params;
const t = await getTranslations({locale, namespace: 'Metadata'});
const pageTranslations = await getTranslations({locale, namespace: 'AuthPage.login'});
const pt = await getTranslations({locale, namespace: 'AuthPage.login'});
return constructMetadata({
title: pageTranslations('title') + ' | ' + t('title'),
title: pt('title') + ' | ' + t('title'),
description: t('description'),
canonicalUrl: `${getBaseUrlWithLocale(locale)}/auth/login`,
});

View File

@ -12,10 +12,10 @@ export async function generateMetadata({
}): Promise<Metadata | undefined> {
const {locale} = await params;
const t = await getTranslations({locale, namespace: 'Metadata'});
const pageTranslations = await getTranslations({locale, namespace: 'AuthPage.register'});
const pt = await getTranslations({locale, namespace: 'AuthPage.register'});
return constructMetadata({
title: pageTranslations('title') + ' | ' + t('title'),
title: pt('title') + ' | ' + t('title'),
description: t('description'),
canonicalUrl: `${getBaseUrlWithLocale(locale)}/auth/register`,
});

View File

@ -12,10 +12,10 @@ export async function generateMetadata({
}): Promise<Metadata | undefined> {
const {locale} = await params;
const t = await getTranslations({locale, namespace: 'Metadata'});
const pageTranslations = await getTranslations({locale, namespace: 'AuthPage.resetPassword'});
const pt = await getTranslations({locale, namespace: 'AuthPage.resetPassword'});
return constructMetadata({
title: pageTranslations('title') + ' | ' + t('title'),
title: pt('title') + ' | ' + t('title'),
description: t('description'),
canonicalUrl: `${getBaseUrlWithLocale(locale)}/auth/reset-password`,
});