svelte-intl-precompile icon indicating copy to clipboard operation
svelte-intl-precompile copied to clipboard

Confusing console warnings

Open Martok88 opened this issue 1 year ago • 0 comments

I'm using this package with SvelteKit, and it works well, but I'm getting a lot of warnings in the browser console like this:

[svelte-intl-precompile] The message "chat_history_1" was not found in "", "en".

Note: there are at least one loader still registered to this locale that wasn't executed.

This is the locale init code in my +layout.svelte:

registerAll();
let lang = "en";
if (browser && navigator.languages && !$settings.language) {
	for (const navLang of navigator.languages) {
		if (Object.keys(localesMap).includes(navLang.slice(0, 2))) {
			lang = navLang.slice(0, 2);
			break;
		}
	}
	$settings.language = lang;
} else if ($settings.language) {
	lang = $settings.language;
}
init({ fallbackLocale: "en", initialLocale: lang });

Object.keys(localesMap) evaluates to an array of 2-letter language codes supported by the app, and $settings.language is the user's language preference, if logged in. I'm seeing the warnings whether logged in or not.

Martok88 avatar Jul 04 '24 18:07 Martok88