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

refactor(i18n): simpler fallback system #8858

Merged
merged 1 commit into from
Oct 18, 2023

Conversation

ematipico
Copy link
Member

@ematipico ematipico commented Oct 18, 2023

Changes

This PR makes the fallback system way simpler. The initial configuration had the idea where a user could define the order of the fallbacks. In the below example, pt_BR will fallback to pt and if pt doesn't have a translation, it will fallback to en.

const i18n = {
	fallback: {
		pt_BR: ['pt', 'en']
	}
}

Nuxt inspired this, although in their latest version, they removed this configuration. Also, other vendors have a simple system.

Also, this complex fallback system would only work if we create a middleware function for each member in the array, and this is overkill.

The new configuration is like this instead:

const i18n = {
	fallback: {
		pt_BR: 'pt'
	}
}

Testing

I updated the test with more test cases.

Docs

@changeset-bot
Copy link

changeset-bot bot commented Oct 18, 2023

⚠️ No Changeset found

Latest commit: 2ff664d

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.

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

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Oct 18, 2023
@ematipico ematipico force-pushed the feat/i18n-routing-fallback-config branch from fbba388 to 9b10000 Compare October 18, 2023 12:24
@ematipico ematipico force-pushed the feat/i18n-routing-fallback-config branch from 9b10000 to 2ff664d Compare October 18, 2023 12:24
@ematipico ematipico merged commit a08dbb4 into feat/i18n-routing Oct 18, 2023
13 checks passed
@ematipico ematipico deleted the feat/i18n-routing-fallback-config branch October 18, 2023 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants