Skip to content

i18n(zh-cn): Update i18n.mdx & Update customization.mdx#933

Merged
delucis merged 2 commits into
withastro:mainfrom
liruifengv:i18n-1019-2
Oct 24, 2023
Merged

i18n(zh-cn): Update i18n.mdx & Update customization.mdx#933
delucis merged 2 commits into
withastro:mainfrom
liruifengv:i18n-1019-2

Conversation

@liruifengv
Copy link
Copy Markdown
Member

@liruifengv liruifengv commented Oct 19, 2023

What kind of changes does this PR include?

  • Changes or translations of Starlight docs site content

Description

  • Update i18n.mdx
  • Update customization.mdx

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Oct 19, 2023

⚠️ No Changeset found

Latest commit: e8671d8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@netlify
Copy link
Copy Markdown

netlify Bot commented Oct 19, 2023

👷 Deploy Preview for astro-starlight processing.

Name Link
🔨 Latest commit e8671d8
🔍 Latest deploy log https://app.netlify.com/sites/astro-starlight/deploys/6530cc91dfd8a200084fd367

@github-actions github-actions Bot added i18n Anything to do with internationalization & translation efforts 📚 docs Documentation website changes labels Oct 19, 2023
@liruifengv
Copy link
Copy Markdown
Member Author

Maybe build-in support languages in i18n.mdx also can be written as a component, like the social component.

Because we support more and more languages.

@liruifengv liruifengv changed the title i18n(zh-cn): Update i18n.mdx i18n(zh-cn): Update i18n.mdx & Update customization.mdx Oct 19, 2023
@HiDeoo
Copy link
Copy Markdown
Member

HiDeoo commented Oct 19, 2023

Maybe build-in support languages in i18n.mdx also can be written as a component, like the social component.

This is an interesting idea.

I guess we could maybe use Intl.DisplayNames to get proper language display names based on the current page locale and Intl.ListFormat to get a listing properly formatted for the current locale, e.g. something like:

// Available at build time
const currentPageLang = "fr";
// Generated based on the list of supported languages
const supportedLangs = ["ar", "en", "fr", "zh-CN"];

const langNames = new Intl.DisplayNames([currentPageLang], {
  type: "language",
});

const langList = new Intl.ListFormat(currentPageLang, {
  style: "long",
  type: "conjunction",
}).format(supportedLangs.map((supportedLang) => langNames.of(supportedLang)));

This would give for example:

  • In English: Arabic, English, French, and Chinese (China)
  • In French: arabe, anglais, français et chinois (Chine)
  • In Chinese: 阿拉伯语、英语、法语和中文(中国)

Copy link
Copy Markdown
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — thanks @liruifengv!

@HiDeoo Would definitely be interested to see that in a PR! I’d actually considered if it was possible before but dismissed it as not possible because of the need to translate the language names — didn’t know about that part of Intl. (Not for the first time you surprise me with Intl magic — I should probably brush up on it.)

@delucis delucis merged commit a372892 into withastro:main Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📚 docs Documentation website changes i18n Anything to do with internationalization & translation efforts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants