Automatically redirects URLs to their preferred language equivalents
Automatically redirects URLs to their preferred language equivalents.
LANGUAGE_CONFIG object/es/ → /ca/)es.site.com → ca.site.com)/page → /ca/page)site.com → ca.site.com)?lang=ca, ?hl=ca)Edit the LANGUAGE_CONFIG object to set your preferred languages:
const LANGUAGE_CONFIG = {
targetLang: "ca", // Primary target language (ISO code)
altLang: "va", // Alternative target language (optional)
};
With default Catalan configuration:
Original: https://example.com/es/products
Redirected to: https://example.com/ca/products
Original: https://en.wikipedia.org/wiki/Barcelona
Redirected to: https://ca.wikipedia.org/wiki/Barcelona
For other languages, just change the configuration:
// French configuration
const LANGUAGE_CONFIG = {
targetLang: "fr",
altLang: null,
};
AGPL-3.0-or-later License