lib icon indicating copy to clipboard operation
lib copied to clipboard

[i18n]: Non-standard locale provided:

Open Swepool opened this issue 3 years ago • 16 comments
trafficstars

Been trying to figure this one out, can't seem to find where it's coming from? Non-standard locale provided: 'static'. Check your 'translations' and 'loaders' in i18n config...

Swepool avatar May 25 '22 22:05 Swepool

There is other unmentioned possibility that your locale static value comes from locale.set(…) (and not from your config). This warning should be definitely updated.. anyway you could use log.level = 'debug' config which should give you more detailed information so maybe then you could see where the wrong locale input comes from..

jarda-svoboda avatar May 25 '22 22:05 jarda-svoboda

Hmm, think it's referring to my static folder for whatever reason 🤔

Swepool avatar May 25 '22 23:05 Swepool

That’s weird, there has to be something wrong in your config (I didn’t notice similar behavior in any of examples and also tests work well).. could you provide some repro?.)

jarda-svoboda avatar May 25 '22 23:05 jarda-svoboda

Hmm weird, haven't really changed anything 🤔

https://github.com/Swepool/nbx-site

Swepool avatar May 25 '22 23:05 Swepool

debug doesn't really give me anything, but everything seems work.

Swepool avatar May 26 '22 00:05 Swepool

Ok, I’ll run it during today, but on a first look I would say there is some bad img src (or other static asset) with route-like url so it’s probably accepted here and/or here

jarda-svoboda avatar May 26 '22 06:05 jarda-svoboda

i just tried and i'm not getting the warning - was it some specific page/app state?

jarda-svoboda avatar May 26 '22 21:05 jarda-svoboda

Make sure you changed the log level or remove it. It's whenever I'm switching page 🤔

Swepool avatar May 26 '22 22:05 Swepool

Ok, that's weird, but it seems that .woff files go through the load function in SvelteKit so it is recognized as a url to parse the locale from... Just tried to insert this supercool log console.log(`lang constant in the __layout 'load' function has '${lang}' value – parsed from '${pathname}' pathname.`); after const lang = ... and getting:

lang constant in the __layout 'load' function has 'static' value – parsed from '/static/fonts/basis-grotesque-bold-pro.woff' pathname.
[i18n]: Non-standard locale provided: 'static'. Check your 'translations' and 'loaders' in i18n config...

lang constant in the __layout 'load' function has 'static' value – parsed from '/static/fonts/basis-grotesque-off-white-pro.woff' pathname.
[i18n]: Non-standard locale provided: 'static'. Check your 'translations' and 'loaders' in i18n config...

lang constant in the __layout 'load' function has 'en' value – parsed from '/en/about' pathname.
// ^^^ This one is correct => no additional warnings

lang constant in the __layout 'load' function has 'static' value – parsed from '/static/fonts/basis-grotesque-regular-pro.woff' pathname.
[i18n]: Non-standard locale provided: 'static'. Check your 'translations' and 'loaders' in i18n config...

Not 100% sure yet, but It seems like a SvelteKit's bug to me...

jarda-svoboda avatar May 26 '22 22:05 jarda-svoboda

Interesting 🤔 hmmm... that's strange..

Swepool avatar May 26 '22 22:05 Swepool

It also prompts this message when adding a “service-worker” file in the project.

[i18n]: Non-standard locale provided: 'service-worker.js'. Check your 'translations' and 'loaders' in i18n config...

R3D2 avatar Jun 14 '22 18:06 R3D2

Not tested yet, but I guess it’s probably the same issue with SvelteKit..

jarda-svoboda avatar Jun 14 '22 19:06 jarda-svoboda

Hello all, I believe the error is due to you NOT using a standard language code. An example of this would be using "jp" for Japan. The correct country abreviation is "ja". For a full list see here: language_codes. Possibly you have "static" as a language Code????

kevin192291 avatar Jun 18 '22 19:06 kevin192291

export const defaultLocale = 'fr';

export const { t, locale, locales, loading, loadTranslations, translations } = new i18n(config);

loading.subscribe(async ($loading) => {
	if ($loading) {
		await loading.toPromise();
	}
});

I'm using 'en' and 'fr', which it seems to be ok.

R3D2 avatar Jun 18 '22 19:06 R3D2

I got this warning for using 'nn' which is in the list.

iverks avatar Jul 07 '22 22:07 iverks

I had this problem, in my case the non standard locale message was 'images'. It was caused by a url to a file ('/images/arrow.svg') that didn't exist anymore. The url was in a scss file that i loaded globaly

ruudtimmermans avatar Aug 03 '22 14:08 ruudtimmermans

Correct me if i'm wrong, but i think that current version of SvelteKit no longer loads static assets through the load function, so i'm closing this issue for now..

jarda-svoboda avatar Jul 06 '23 19:07 jarda-svoboda