Skip to content

Set lang attribute to language labels #4927

@tats-u

Description

@tats-u

Describe the bug

lang attibute to language labels in the language switcher (文A) makes the shape of each han correct in all system locales.

If you vary the value of lang, you will get:

🇯🇵简体中文 繁體中文 日本語
🇨🇳简体中文 繁體中文 日本語
🇹🇼简体中文 繁體中文 日本語
🇭🇰简体中文 繁體中文 日本語
🇰🇷简体中文 繁體中文 日本語

  • The first stroke of 文 and 語
  • 骨 in 體
  • 糸 in 繁

Without that attribute, the forms in the system locale language are used. (e.g. If your OS is Japanese, all han where lang is non-CJK are set to Japanese shapes)

Reproduction

Visit a site with i18n using VitePress (at least 2 of Japanese, Simplified Chinese, and Traditional Chinese exist):

  1. Analyze tags wrapping language labels
  2. Determine whether Each han in each CJK language is displayed as the expected/correct form (except for some environment, e.g. Windows + Firefox (the OS locale is prioritized))

Wrong:

Image Image

Expected behavior

  1. lang attribute (e.g. lang=zh-CN or lang=ja) is added to one of ancestor tags of each language label
  2. Each han is displayed as the correct/expected form

Correct:

Set the correct lang attribute values to Simplified/Traditional Chinese labels:

Image

↓Note: Japanese is prioritized due to system-ui and ui-sans-serif, so this is not ideal:

Image

(sans-serif instead of them will fix the shape of 文)

System Info

N/A

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions