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

UI text not translated when creating a multilingual site with only one locale #1556

Closed
1 task
sschultze opened this issue Feb 24, 2024 · 3 comments · Fixed by #1709
Closed
1 task

UI text not translated when creating a multilingual site with only one locale #1556

sschultze opened this issue Feb 24, 2024 · 3 comments · Fixed by #1709
Labels
🐛 bug Something isn't working i18n Anything to do with internationalization & translation efforts

Comments

@sschultze
Copy link

sschultze commented Feb 24, 2024

What version of starlight are you using?

0.20.1

What version of astro are you using?

4.4.4

What package manager are you using?

npm

What operating system are you using?

Mac

What browser are you using?

Brave

Describe the Bug

If I create a multilingual site with only one non-English locale like this, the UI text (like "On this page") is not translated, but always English instead.

defaultLocale: 'de',
locales: {
    de: {
        lang: 'de',
        label: 'Deutsch'
    }
},

As soon as I add another locale, for example fr, the UI text of the de locale is correctly translated to German.

Why am I trying to create a multilingual site with only one locale in the first place? I want to prepare for translations in the future.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-4oxm53?file=astro.config.mjs

You have to visit /de/ in Stackblitz manually. For some reason, the redirect from / to /de/ doesn't seem to work in Stackblitz - in my local installation, it does.

Participation

  • I am willing to submit a pull request for this issue.
@sschultze sschultze changed the title UI text not translated when creating a multi-lingual site with only one locale UI text not translated when creating a multilingual site with only one locale Feb 24, 2024
@delucis
Copy link
Member

delucis commented Feb 24, 2024

Thank you for the report and the clear reproduction @sschultze!

I can confirm I’m seeing the same thing in your StackBlitz link. I think we never accounted for this situation with the expectation that monolingual sites always used the root as the default locale (as shown in our i18n guide), but this should work.

@delucis delucis added 🐛 bug Something isn't working i18n Anything to do with internationalization & translation efforts labels Feb 24, 2024
@sschultze
Copy link
Author

Thank you @delucis !

@rgilsimoes
Copy link
Contributor

I did a little debugging and found out that the when returning the UserConfig it's expected to have "root" present but because of the Zod configuration it is not mandatory.

This would be fixed by changing this on user-config.ts:

	/** Configure locales for internationalization (i18n). */
	locales: z
		.object({
			/** Configure a “root” locale to serve a default language from `/`. */
			root: LocaleSchema.required({ lang: true }).required(),
		})

Either way I've also noticed that if we set "root" plus another locale setting the "defaultLocale" has no effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working i18n Anything to do with internationalization & translation efforts
Projects
None yet
3 participants