0

#/mapping/date.js

import { translationMacro as t } from "ember-i18n"; 
export default {
  i18n: Ember.inject.service(),
  DateFilter: {
    today: "Today",
    yesterday: "Yesterday",
    thisWeek: "This Week",
    lastWeek: "Last Week",
    thisMonth: "This Month",
    lastMonth: "Last Month",
    none: "None"
  }

我尝试使用帮助器作为 {{t "Today"}},宏作为(t "Today") 和服务注入作为 this.get('i18n').t('Today').toString(),其中 'Today ' 是一个键,但它们都不起作用。另外,如何翻译 .scss 文件中的字符串?例如下面代码中的“打开文件”。

&::after{
            position: absolute;
            content: 'Open file';
            font-size: 12px;
            color: $secondary-button;
            bottom: 16px;
            left: 16px;
        } 
4

1 回答 1

0

除非您将“今天”指定为 中的键之一your-locale/translation.js,否则这将不起作用。

我猜您可能想在帮助程序中使用该属性而不是硬编码字符串{{t}}。使用{{t DateFilter.today}}. DateFilter.today 是一个控制器属性,它将返回字符串 'today'

于 2018-07-11T07:20:39.327 回答