Closed ctjhoa closed 4 years ago
The idea with tVar
(or {{t-var}}
) is that it can be for things that are dynamic. You will need to make sure yourself that it is picked up somewhere else. For example, this could work:
export default class DynamicValuesService extends Service {
@service l10n;
constructor() {
super(...arguments);
let { l10n } = this;
this.values = [
l10n.t('Old'),
l10n.t('New')
];
}
}
{{! template, where @status might be "Old" or "New" }}
Status: {{t-var @status}}
In most cases, it will probably be better to avoid this if possible, and use manual mapping instead, e.g.:
export default class MyComponent extends Component {
@service l10n;
constructor() {
super(...arguments);
let { l10n } = this;
this.statusMap = [
'Old': l10n.t('Old'),
'New': l10n.t('New')
];
}
}
Status: {{get this.statusMap @status}}
Hi,
Can you explain a little more how
tVar
works? I understand thattVar
is to ignore an entry in the parsing/extracting phase however you still want a translation for that entry at some point. So how do you provide a translation fortVar
if it's not with theextract
command?