简体   繁体   English

离子单一语言

[英]Ionic Single Language

I want to make my application support only one language (for the components like calendar etc.) even though the device language is a different language. 我想让我的应用程序仅支持一种语言(对于日历等组件),即使设备语言是另一种语言。

In this picture, as you can see the application language is Turkish but the buttons and the months are English. 在这张图片中,您可以看到应用程序语言是土耳其语,但按钮和月份是英语。 I want them all to be Turkish. 我希望他们都是土耳其人。

在此输入图像描述

Just like you can see in 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 目前,根据语言或语言环境,没有一个通用的标准可以自动为月份名称或星期几名称选择正确的语言/拼写。

And

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 Config Level App配置级别

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

Component Input Level 组件输入级别

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

And in order to change the text of the buttons: 并且为了更改按钮的文本:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM