How to use the svelte-i18n.locale.set function in svelte-i18n

To help you get started, we’ve selected a few svelte-i18n examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github caos / zitadel / site / src / i18n.js View on Github external
const headerLngs = req.headers['accept-language'].split(',');
                const headerLngCodes = headerLngs.map(lng => lng.split(';')[0].trim());
                const headerLang = headerLngCodes.find(code => {
                    return INIT_OPTIONS.localeOptions.find(option => option == code);
                });

                if (headerLang) {
                    locale = headerLang;
                }
            } else {
                locale = INIT_OPTIONS.initialLocale || INIT_OPTIONS.fallbackLocale;
            }
        }

        if (locale != null && locale !== currentLocale) {
            $locale.set(locale);
        }

        next();
    };
}

svelte-i18n

Internationalization library for Svelte

MIT
Latest version published 18 days ago

Package Health Score

80 / 100
Full package analysis