如何在法语版中使用 ngx_bootstrap datepicker
How to use ngx_bootstrap datepicker with frensh version
我在我的 angular 项目中使用 ngx-bootstrap datepicker,我想使用 datepicker 的法语版本,但它总是以英文版本给出我的代码:
html :
<input type='text' class="form-control" placeholder="Date de l'aller :" bsDatepicker formControlName="dateDepart" />
component.ts:
import { defineLocale } from 'ngx-bootstrap/chronos';
import { fr } from 'ngx-bootstrap/locale';
defineLocale('fr', fr);
关于如何在法文版中使用 ngx-boostrap datepicker 的任何帮助?
您似乎定义了语言环境,但实际上并未设置。从组件中的 ngx-bootstrap/datepicker
注入 BsLocaleService
并调用它的 use('fr')
方法。在此处检查示例 - https://valor-software.com/ngx-bootstrap/#/datepicker#locales(转到 component
选项卡并查看代码)
也可以在 Angular.
的模块中为 ngx-bootstrap 日期选择器设置语言环境
首先我们在 app.module.ts 中导入我们的语言环境:
import { defineLocale } from "ngx-bootstrap/chronos";
import { nbLocale } from "ngx-bootstrap/locale";
defineLocale("nb", nbLocale); //only setting up Norwegian bokmaal (nb) in this sample
export class AppModule {
constructor(private bsLocaleService: BsLocaleService) {
this.bsLocaleService.use('nb');
}
}
现在我们所有的 ngx-bootstrap 日期选择器都将具有指定的语言环境挪威语。您当然可以切换到其他语言环境,请记住将当地人的字符串文字输入为小写。
对于西班牙语(日期选择器),将此代码添加到 app.module:
import { BsDatepickerModule, BsLocaleService } from 'ngx-bootstrap/datepicker';
import { defineLocale } from 'ngx-bootstrap/chronos';
import { esLocale } from 'ngx-bootstrap/locale';
defineLocale('es', esLocale);
export class AppModule {
constructor( private bsLocaleService: BsLocaleService){
this.bsLocaleService.use('es');//fecha en español, datepicker
}
}
我在我的 angular 项目中使用 ngx-bootstrap datepicker,我想使用 datepicker 的法语版本,但它总是以英文版本给出我的代码:
html :
<input type='text' class="form-control" placeholder="Date de l'aller :" bsDatepicker formControlName="dateDepart" />
component.ts:
import { defineLocale } from 'ngx-bootstrap/chronos';
import { fr } from 'ngx-bootstrap/locale';
defineLocale('fr', fr);
关于如何在法文版中使用 ngx-boostrap datepicker 的任何帮助?
您似乎定义了语言环境,但实际上并未设置。从组件中的 ngx-bootstrap/datepicker
注入 BsLocaleService
并调用它的 use('fr')
方法。在此处检查示例 - https://valor-software.com/ngx-bootstrap/#/datepicker#locales(转到 component
选项卡并查看代码)
也可以在 Angular.
的模块中为 ngx-bootstrap 日期选择器设置语言环境首先我们在 app.module.ts 中导入我们的语言环境:
import { defineLocale } from "ngx-bootstrap/chronos";
import { nbLocale } from "ngx-bootstrap/locale";
defineLocale("nb", nbLocale); //only setting up Norwegian bokmaal (nb) in this sample
export class AppModule {
constructor(private bsLocaleService: BsLocaleService) {
this.bsLocaleService.use('nb');
}
}
现在我们所有的 ngx-bootstrap 日期选择器都将具有指定的语言环境挪威语。您当然可以切换到其他语言环境,请记住将当地人的字符串文字输入为小写。
对于西班牙语(日期选择器),将此代码添加到 app.module:
import { BsDatepickerModule, BsLocaleService } from 'ngx-bootstrap/datepicker';
import { defineLocale } from 'ngx-bootstrap/chronos';
import { esLocale } from 'ngx-bootstrap/locale';
defineLocale('es', esLocale);
export class AppModule {
constructor( private bsLocaleService: BsLocaleService){
this.bsLocaleService.use('es');//fecha en español, datepicker
}
}