Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(translations): add workaround for site title and tagline translations #95

Merged
merged 1 commit into from
Jul 31, 2024
Merged
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
29 changes: 27 additions & 2 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,35 @@ import tailwindPlugin from './plugins/tailwind-config.cjs';
const baseUrl = '/ai-unlimited-docs';
const projectName = 'ai-unlimited-docs';

const getCurrentLocale = () => process.env.DOCUSAURUS_CURRENT_LOCALE ?? 'en';

/**
* This is a workaround for translations of site title and tagline.
* Docusaurus does not support translations for title and tagline in site config yet.
* Refer to: https://github.com/facebook/docusaurus/issues/4542 for details
*/
const getSiteTagline = () => {
// Add translations for the tagline in the switch case
switch (getCurrentLocale()) {
case 'en':
default:
return 'A scalable, on-demand compute engine in the cloud.';
}
};

const getSiteTitle = () => {
// Add translations for the title in the switch case
switch (getCurrentLocale()) {
case 'en':
default:
return 'Teradata AI Unlimited Documentation';
}
};

/** @type {import('@docusaurus/types').Config} */
const config = {
title: 'home_page.title',
tagline: 'home_page.tagline',
title: getSiteTitle(),
tagline: getSiteTagline(),
favicon: 'img/favicon.ico',

// Set the production url of your site here
Expand Down
8 changes: 3 additions & 5 deletions src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ function HomepageHeader() {
<div className={clsx('container', styles.container)}>
<div className="">
<Heading as="h1" className="hero__title">
{translate({ message: siteConfig.title })}
{siteConfig.title}
</Heading>
<p className="hero__subtitle">
<Translate id={siteConfig.tagline} />
</p>
<p className="hero__subtitle">{siteConfig.tagline}</p>
<div className={styles.buttons}>
<Link
className={clsx(
Expand Down Expand Up @@ -47,7 +45,7 @@ function HomepageHeader() {
export default function Home() {
const { siteConfig } = useDocusaurusContext();
return (
<Layout description={translate({ message: siteConfig.tagline })}>
<Layout description={siteConfig.tagline}>
<HomepageHeader />
<main className={styles.features}>
<HomepageFeatures />
Expand Down