Currently, I am developing a web screen within a .NET application and facing an issue with sending datetime preferences from the system to the web screen using CefSharp settings.
AcceptLanguageList = CultureInfo.CurrentUICulture.Name
In my TypeScript code, I need to utilize dayjs and dynamically import 'dayjs/locale/${language}' where the language is fetched from AcceptLanguageList mentioned above.
import React, { useState } from 'react';
import dayjs, { Dayjs } from 'dayjs';
import localeData from 'dayjs/plugin/localeData';
dayjs.extend(localeData);
var lang = navigator.languages != null ? navigator.languages[0] : navigator.language;
lang = lang.toLowerCase();
import(`dayjs/locale/${lang}`).then(
() => {
dayjs.locale(lang);
setAdapterLocale(lang);
});
The issue arises when running this code in the browser. Importing 'dayjs/locale/fr-ca', for instance, works fine but if 'fr-ca' comes from CefSharp, the import fails with the following error:
Uncaught (in promise) TypeError: Failed to resolve module specifier 'dayjs/locale/fr-ca'
I would greatly appreciate any assistance on this matter.