vuepress / vuepress-community

:bulb: Community supported ecosystem for VuePress
https://vuepress-community.netlify.app
MIT License
81 stars 62 forks source link

Fix #34: Introduce fuzzyLocales option to redirect #35

Closed TiEul closed 4 years ago

TiEul commented 4 years ago

Summary

This change introduces the fuzzyLocales option to the redirect plugin. It allows users to configure the language-based redirects in a way that they only take the language into account while ignoring specific dialects. For example, this means that users with browsers that sendde-AT as a locale will still be forwarded to the de-DE locale, as the plugin will only take the lowercase de into account while ignoring the region-specific uppercase DE and AT. This is only a fallback, so if both exist, users will be forwarded to the appropriate dialect version of their language.

Which package does this PR involve? (check one)

What kind of change does this PR introduce? (check at least one)

Does this PR introduce a breaking change? (check one)

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

Other information:

https://github.com/vuepress/vuepress-community/issues/34

TiEul commented 4 years ago

@meteorlxy Let me know if I need to fix anything here or if you have any objections to this PR in general. Just as a note, I actually think the behavior I added should be the default behavior, I merely added the option to turn it off to not cause any backwards-breaking behaviors. Generally, I would assume that choosing the closest fallback language is better than "randomly" choosing English, for example.