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

feat: Support object title for multiple language #1620

Merged
merged 43 commits into from Apr 30, 2024
Merged

Conversation

emjio
Copy link
Contributor

@emjio emjio commented Mar 18, 2024

Description

The title config can be translate by Object type.

title object key must be BCP-47 tag e.g. "en", "ar", or "zh-CN"

// title as string
export default defineConfig({
	integrations: [
		starlight({
			title: 'Starlight',
		}),
	],
});
// translate title by object
export default defineConfig({
	integrations: [
		starlight({
			title: {
                            en: 'Starlight',
                            'zh-CN': '星光',
                          },
		}),
	],
});

Title must have a key for the default language

// below code Will throw a error
export default defineConfig({
	integrations: [
		starlight({
			title: {
                            'zh-CN': '星光',
                          },
                         defaultLocale: 'en'
		}),
	],
});

Docs update

  1. Update the type of title and add a new usage code example in docs/src/content/docs/configuration.mdx
  2. Description of the new siteTitle field in docs/src/content/docs/reference/overrides.md
  3. Multi-language instructions for the new title in docs/src/content/docs/guides/i18n.mdx

Copy link

changeset-bot bot commented Mar 18, 2024

🦋 Changeset detected

Latest commit: 035b38d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@astrojs/starlight Minor

Not sure what this means? Click here to learn what changesets are.

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

Copy link

vercel bot commented Mar 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
starlight ✅ Ready (Inspect) Visit Preview Apr 30, 2024 11:03am
starlight-i18n 🔄 Building (Inspect) Visit Preview Apr 30, 2024 11:03am

@github-actions github-actions bot added 📚 docs Documentation website changes 🌟 core Changes to Starlight’s main package labels Mar 18, 2024
@astrobot-houston
Copy link
Collaborator

Hello! Thank you for opening your first PR to Starlight! ✨

Here’s what will happen next:

  1. Our GitHub bots will run to check your changes.
    If they spot any issues you will see some error messages on this PR.
    Don’t hesitate to ask any questions if you’re not sure what these mean!

  2. In a few minutes, you’ll be able to see a preview of your changes on Vercel 🤩

  3. One or more of our maintainers will take a look and may ask you to make changes.
    We try to be responsive, but don’t worry if this takes a few days.

Copy link
Sponsor Member

@liruifengv liruifengv left a comment

Choose a reason for hiding this comment

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

Thanks for your work about this feature. I leave some suggestion.

  • The title of the starlight document does not need to be changed.
  • The title config need to support both string and object type.
  • Update the Header's UI title in SiteTitle.astro
  • You can add a changeset by run pnpm exec changeset
  • You need update the docs in configuration

docs/astro.config.mjs Outdated Show resolved Hide resolved
docs/astro.config.mjs Outdated Show resolved Hide resolved
packages/starlight/utils/user-config.ts Outdated Show resolved Hide resolved
@github-actions github-actions bot removed the 📚 docs Documentation website changes label Mar 18, 2024
@emjio emjio marked this pull request as draft March 19, 2024 03:43
@github-actions github-actions bot added i18n Anything to do with internationalization & translation efforts 📚 docs Documentation website changes labels Mar 19, 2024
@emjio emjio marked this pull request as ready for review March 19, 2024 05:11
@emjio emjio requested a review from liruifengv March 19, 2024 05:11
@github-actions github-actions bot removed i18n Anything to do with internationalization & translation efforts 📚 docs Documentation website changes labels Mar 19, 2024
Co-authored-by: liruifengv <liruifeng1024@gmail.com>
@astrobot-houston
Copy link
Collaborator

astrobot-houston commented Apr 30, 2024

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

Locale File Note
en guides/i18n.mdx Source changed, localizations will be marked as outdated.
en reference/configuration.mdx Source changed, localizations will be marked as outdated.
en reference/overrides.md Source changed, localizations will be marked as outdated.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

Copy link
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.

Thanks again for your patience with this PR @emjio! I just revised the documentation changes and this PR is ready to merge in our next release.

Thank you for adding this very helpful feature — we really appreciate you taking the time 🚀

Thanks also to @liruifengv for championing and helping review this idea 💖

@delucis delucis added the 🌟 minor Change that triggers a minor release label Apr 30, 2024
Copy link
Sponsor Member

@liruifengv liruifengv left a comment

Choose a reason for hiding this comment

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

LGTM. Congratulations!

@delucis delucis merged commit ca0678c into withastro:main Apr 30, 2024
10 checks passed
@astrobot-houston astrobot-houston mentioned this pull request Apr 30, 2024
liruifengv added a commit to liruifengv/starlight that referenced this pull request May 7, 2024
HiDeoo added a commit that referenced this pull request May 8, 2024
Co-authored-by: HiDeoo <494699+HiDeoo@users.noreply.github.com>
Co-authored-by: huyikai <25839948+huyikai@users.noreply.github.com>
HiDeoo added a commit to HiDeoo/starlight that referenced this pull request May 8, 2024
* main:
  i18n(zh-cn): Update docs about synced-tabs (withastro#1834)
  i18n(zh-cn): Update some docs about withastro#1620 & withastro#1613 (withastro#1835)
  Add more diagnostic help to error messages thrown by `<Steps>` (withastro#1838)
  i18n(zh-cn): Update components.mdx (withastro#1836)
  i18n(zh-cn): Update community-content.mdx (withastro#1833)
  Improve type checking job (withastro#1831)
  [ci] format
  [ci] release (withastro#1832)
  i18n(ru): update ru.json (withastro#1826)
  Fix `<Tabs>` sync issue with inconsistent use of `icon` on `<TabItem>` components (withastro#1811)
  Enable `BASE_URL` tests (withastro#1828)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌟 core Changes to Starlight’s main package 📚 docs Documentation website changes 🌟 minor Change that triggers a minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants