UNPKG

@vyxos/astro-i18next

Version:

I18next integration for Astro with dynamic namespace loading.

33 lines (30 loc) 1.13 kB
'use strict'; // src/utils/config.ts function getConfigOptions() { if (typeof window !== "undefined" && window.__astroI18nConfig) { return window.__astroI18nConfig; } if (typeof globalThis !== "undefined" && globalThis.__astroI18nConfig) { return globalThis.__astroI18nConfig; } throw new Error( "[astro-i18next] Configuration not available. Make sure the integration is properly configured." ); } // src/utils/localization.ts function getLocalizedPathname(pathname, locale = "") { const { defaultLocale, locales } = getConfigOptions(); const localeFromPathname = pathname.split("/")[1]; let localizedPathname = pathname; if (locales.includes(localeFromPathname)) { localizedPathname = localizedPathname.replace("/" + localeFromPathname, "") || "/"; } if (locales.includes(locale) && locale !== defaultLocale) { localizedPathname = "/" + locale + localizedPathname.replace(/^\/$/, ""); } return localizedPathname; } exports.getLocaleConfig = getConfigOptions; exports.getLocalizedPathname = getLocalizedPathname; //# sourceMappingURL=utils.cjs.map //# sourceMappingURL=utils.cjs.map