5 twitter-bootstrap ngx-bootstrap angular
我在我的 angular 项目中使用 ngx-bootstrap datepicker,我想使用法语版本的 datepicker,但它总是以英文版本给出我的代码:
html :
<input type='text' class="form-control" placeholder="Date de l'aller :" bsDatepicker formControlName="dateDepart" />
Run Code Online (Sandbox Code Playgroud)
组件.ts:
import { defineLocale } from 'ngx-bootstrap/chronos';
import { fr } from 'ngx-bootstrap/locale';
defineLocale('fr', fr);
Run Code Online (Sandbox Code Playgroud)
关于如何在法语版本中使用 ngx-boostrap datepicker 有什么帮助吗?
小智 8
对于西班牙语(Datepicker),请将此代码添加到 app.module :
\n\nimport { BsDatepickerModule, BsLocaleService } from 'ngx-bootstrap/datepicker';\nimport { defineLocale } from 'ngx-bootstrap/chronos';\nimport { esLocale } from 'ngx-bootstrap/locale';\ndefineLocale('es', esLocale);\n\nexport class AppModule { \n constructor( private bsLocaleService: BsLocaleService){\n this.bsLocaleService.use('es');//fecha en espa\xc3\xb1ol, datepicker\n }\n\n}\n
Run Code Online (Sandbox Code Playgroud)\n
也可以在 Angular 的模块中为 ngx-bootstrap datepicker 设置语言环境。
首先,我们在 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');
}
}
Run Code Online (Sandbox Code Playgroud)
现在我们所有的 ngx-bootstrap 日期选择器都将具有指定的挪威语语言环境。您当然可以切换到其他语言环境,请记住将本地语言的字符串文字输入为小写。
看起来您定义了区域设置但尚未实际设置它。BsLocaleService
从ngx-bootstrap/datepicker
您的组件中注入并调用其use('fr')
方法。检查此处的示例 - https://valor-software.com/ngx-bootstrap/#/datepicker#locales(转到component
选项卡并查看代码)
归档时间: |
|
查看次数: |
8960 次 |
最近记录: |