Skip to content

Commit

Permalink
Merge pull request #81 from xen0n/i18n
Browse files Browse the repository at this point in the history
i18n groundwork
  • Loading branch information
xen0n authored Jan 1, 2025
2 parents 7b02b6e + 5e4b5d6 commit 5102218
Show file tree
Hide file tree
Showing 26 changed files with 1,434 additions and 44 deletions.
2 changes: 2 additions & 0 deletions art/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@
* `logo-readme.svg``logo.svg``for-repo-readme` 图层粘贴过来再去掉那个底部矩形的结果。
* `logo-readme.png``logo-readme.svg` 用 Inkscape 导出后 `pngcrush` 的结果。
* `logo-site.svg` 是将 `logo.svg``chinese` 图层的内容挪到 32x144 画布另存为的结果。
* `logo-site-en.svg` 是将 `logo.svg``english title` 图层的内容挪到 32x252 画布另存为的结果。
* `static/img/logo.svg` 是在 Inkscape 中另存 `logo-site.svg` 为优化的 SVG 的结果。
* `static/img/logo.svg` 是在 Inkscape 中另存 `logo-site-en.svg` 为优化的 SVG 的结果。
* `static/img/favicon.ico` 是在 Gimp 将 `favicon.xcf` 先合并为单个图层再保存为 Windows ICO 格式的结果。
295 changes: 295 additions & 0 deletions art/logo-site-en.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 54 additions & 11 deletions docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,48 @@ const commonRehypePlugins = [
],
]

// i18n workarounds
// see https://github.com/facebook/docusaurus/issues/4542
// and https://github.com/facebook/docusaurus/pull/8677
const defaultLocale = 'zh-Hans'
process.env.DOCUSAURUS_CURRENT_LOCALE ??= defaultLocale
if (process.env.DOCUSAURUS_CURRENT_LOCALE == 'undefined') {
// this is also happening for some reason...
process.env.DOCUSAURUS_CURRENT_LOCALE = defaultLocale
}

const configStringsTranslations = {
en: {
title: 'AREWELOONGYET?',
tagline: 'Your one-stop portal for following LoongArch upstream work.',
logoPath: 'img/logo-en.svg',
twilTitle: 'This Week in LoongArch',
twilDescription:
'This Week in LoongArch (TWiL) is a weekly newsletter covering the latest developments in the LoongArch community, publishing every Monday.',
siteNewsTitle: 'Site news',
siteNewsDescription:
'News on the development and operations of the AREWELOONGYET? site.',
},
'zh-Hans': {
title: '咱龙了吗?',
tagline: '一站式了解 LoongArch 的上游生态建设。',
logoPath: 'img/logo.svg',
twilTitle: '每周一龙',
twilDescription:
'龙架构新世界生态建设周报《每周一龙》(This Week in LoongArch)。每周一都为大家报道 LoongArch 社区最前线的第一手新鲜资讯!',
siteNewsTitle: '本站动态',
siteNewsDescription: '《咱龙了吗?》网站本身的开发、运营动态。',
},
}

const localizeConfigString = (key: string) => {
const locale = process.env.DOCUSAURUS_CURRENT_LOCALE ?? defaultLocale
return configStringsTranslations[locale][key]
}

const config: Config = {
title: '咱龙了吗?',
tagline: '一站式了解 LoongArch 的上游生态建设。',
title: localizeConfigString('title'),
tagline: localizeConfigString('tagline'),
url: 'https://areweloongyet.com',
baseUrl: '/',
onBrokenLinks: 'throw',
Expand All @@ -55,8 +94,8 @@ const config: Config = {
// metadata like html lang. For example, if your site is Chinese, you may want
// to replace "en" with "zh-Hans".
i18n: {
defaultLocale: 'zh-Hans',
locales: ['zh-Hans'],
defaultLocale: defaultLocale,
locales: [defaultLocale, 'en'],
},

future: {
Expand Down Expand Up @@ -157,9 +196,8 @@ const config: Config = {
id: 'blog-newsletter',
routeBasePath: 'newsletter',
path: './newsletter',
blogTitle: '每周一龙',
blogDescription:
'龙架构新世界生态建设周报《每周一龙》(This Week in LoongArch)。每周一都为大家报道 LoongArch 社区最前线的第一手新鲜资讯!',
blogTitle: localizeConfigString('twilTitle'),
blogDescription: localizeConfigString('twilDescription'),
editUrl:
'https://github.com/loongson-community/areweloongyet/edit/main',
beforeDefaultRemarkPlugins: commonBeforeDefaultRemarkPlugins,
Expand All @@ -182,8 +220,8 @@ const config: Config = {
rehypePlugins: commonRehypePlugins,
},
blog: {
blogTitle: '本站动态',
blogDescription: '《咱龙了吗?》网站本身的开发、运营动态。',
blogTitle: localizeConfigString('siteNewsTitle'),
blogDescription: localizeConfigString('siteNewsDescription'),
showReadingTime: true,
// Please change this to your repo.
// Remove this to remove the "edit this page" links.
Expand Down Expand Up @@ -221,7 +259,7 @@ const config: Config = {
title: '',
logo: {
alt: 'My Site Logo',
src: 'img/logo.svg',
src: localizeConfigString('logoPath'),
},
items: [
{
Expand All @@ -235,9 +273,14 @@ const config: Config = {
{ to: '/blog', label: '本站动态', position: 'left' },
{
href: 'https://github.com/loongson-community/areweloongyet',
label: 'GitHub',
position: 'right',
// use the GitHub icon instead of text for the link (for desktop
// displays), to conserve horizontal space
// https://github.com/facebook/docusaurus/issues/2634
className: 'header--github-link',
'aria-label': 'GitHub repository of the website',
},
{ type: 'localeDropdown', position: 'right' },
],
},
footer: {
Expand Down
Loading

0 comments on commit 5102218

Please sign in to comment.