ngx-bootstrap "en" 缺少区域设置



我正在使用ngx-bootstrap进行工作,我需要日期选择器的语言环境部分。 https://valor-software.com/ngx-bootstrap/#/datepicker#locales 我在上面的网站上检查了一下,我看到了这个:

在这张图片上,我可以看到"en"区域设置,它显示了从星期日开始的英语日期选择器

问题:我的应用程序中只有"enGb"语言环境可用

。此处"en"区域设置导致错误

有什么解决方案,所以我可以在周日启动"enGb"日期选择器,或者获得已经在周日自行启动的"en"区域设置。

提前感谢您的关注。

(我使用@2.0.5 ngx引导版本(

在我的 angular 项目的升级过程中,我为 ngx-bootstrap(版本:2.0.5(调整了以下内容:

// OLD CODE: import { defineLocale }      from 'ngx-bootstrap/bs-moment';
import { defineLocale }                   from 'ngx-bootstrap/chronos';
// OLD CODE: import { nl, es, enGb }      from 'ngx-bootstrap/locale';
import { nlLocale, esLocale, enGbLocale}  from 'ngx-bootstrap/locale';
setLocale(lang: string) {
// Default locale corresponds with lang
let locale = lang;
switch (lang) {
case 'nl': {
// OLD CODE:  defineLocale('nl', nl);
defineLocale('nl', nlLocale);
break;
}
...
}

然后它奏效了。

我对这个问题的解决方案是改变:

defineLocale('en', enLocale); // throws error because enLocale doesn't exist

自:

defineLocale('en'); // works, week is starting on sunday

根据它们的源文件,"en"是未使用配置参数时使用的默认语言。我还没有找到任何关于此的文档,所以我希望这对面临此问题的其他人有用。

编辑:找到可能的解决方案,从他们的源文件中,似乎您必须导入语言环境,不是从区域设置文件夹,而是从ngx-bootstrap/chronos文件夹中导入

这是我试图远离ngx-bootstrap的众多原因之一,他们有很多错误,以及很多他们从未解决的开放票证。他们遇到了一个下拉菜单实际上不起作用的问题,就像在 6 个月的大部分时间里根本没有工作一样,不确定他们是否曾经修复过它。我使用 https://ng-bootstrap.github.io/#/home 作为替代方案。

另外,在他们的github上检查这个文件:https://github.com/valor-software/ngx-bootstrap/blob/development/src/locale.ts 您会注意到enLocale也无处可寻。所以,这看起来是Valorsoft的另一个错误。

我没有使用过他们名为chronos的库,但是如果您将其安装到项目中,则可以尝试直接从chronos库导入。(快速谷歌搜索没有返回任何关于Chronos图书馆的内容。

最新更新