本文整理汇总了TypeScript中aurelia-i18n.I18N.tr方法的典型用法代码示例。如果您正苦于以下问题:TypeScript I18N.tr方法的具体用法?TypeScript I18N.tr怎么用?TypeScript I18N.tr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aurelia-i18n.I18N
的用法示例。
在下文中一共展示了I18N.tr方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: toView
/**
* convert a Date-String into a localized representation
* @param {number} value the value to convert
* @param {"full" | "date" | "time"} mode defaults to "full"
* @returns {string} the localized representation or "" if the value could not be converted
*/
public toView(value: string, mode: "full" | "date" | "time" = "full") {
let ret = "";
if (mode === "full") {
ret = moment(value).format(this.t.tr("adapters.datetime_format"));
} else if (mode === "date") {
ret = moment(value).format(this.t.tr("adapters.date_format"));
} else {
ret = moment(value).format(this.t.tr("adapters.time_format"));
}
return ret ? (ret.startsWith("Invalid") ? "" : ret) : "";
}
示例2: fromView
public fromView(value: string, mode: "full" | "date" | "time" = "full") {
switch (mode) {
case "full":
return moment(
value,
this.t.tr("adapters.datetime_format_parse")
).format();
case "date":
return moment(value, this.t.tr("adapters.date_format_parse")).format();
case "time":
return moment(value, this.t.tr("adapters.time_format_parse")).format();
default:
return moment(value).format();
}
}
示例3: toView
public toView(num: number, mode: "cents"){
const br = Math.round(num) / 100
return this.i18.tr("billing.currency") + " " + br
}
示例4: fromView
fromView(str) {
return moment(str, this.i18.tr('adapters.time_format'))
}
示例5: toView
toView(mom: moment.Moment) {
mom = mom || moment()
return mom.format(this.i18.tr('adapters.time_format'))
}
示例6: activate
activate(model) {
let translated = this.i18n.tr(model.key);
let converter = new showdown.Converter({ extensions: ['targetblank'] });
this.html = converter.makeHtml(translated);
}