加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

角度 – 离子单一语言

发布时间:2020-12-14 04:55:25 所属栏目:百科 来源:网络整理
导读:我想让我的应用程序仅支持一种语言(对于日历等组件),即使设备语言是另一种语言. 在这张图片中,您可以看到应用程序语言是土耳其语,但按钮和月份是英语.我希望他们都是土耳其人. 解决方法 就像你在 the docs中看到的那样: At this time,there is no one-size-
我想让我的应用程序仅支持一种语言(对于日历等组件),即使设备语言是另一种语言.

在这张图片中,您可以看到应用程序语言是土耳其语,但按钮和月份是英语.我希望他们都是土耳其人.

enter image description here

解决方法

就像你在 the docs中看到的那样:

At this time,there is no one-size-fits-all standard to automatically
choose the correct language/spelling for a month name,or day of the
week name,depending on the language or locale

All things considered,the by far easiest solution is to just provide
an array of names if the app needs to use names other than the default
English version of month and day names. The month names and day names
can be either configured at the app level,or individual ion-datetime
level.

App配置级别

//app.module.ts
@NgModule({
...,imports: [
  IonicModule.forRoot(MyApp,{
  monthNames: ['janeiro','fevereiro','maru00e7o',... ],monthShortNames: ['jan','fev','mar',dayNames: ['domingo','segunda-feira','teru00e7a-feira',dayShortNames: ['dom','seg','ter',})
],...
})

组件输入级别

<ion-item>
  <ion-label>Período</ion-label>
  <ion-datetime displayFormat="DDDD MMM D,YYYY" [(ngModel)]="myDate"
    monthNames="janeiro,fevereiro,maru00e7o,..."
    monthShortNames="jan,fev,mar,..."
    dayNames="domingo,segunda-feira,teru00e7a-feira,..."
    dayShortNames="dom,seg,ter,..."></ion-datetime>
</ion-item>

并且为了更改按钮的文本:

<ion-datetime cancelText="'CustomCancel'" doneText="'CustomDone'" ...></ion-datetime>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读