【发布时间】:2021-06-24 10:35:25
【问题描述】:
我正在尝试将 i18n 翻译服务密钥作为参数函数传递给 html 组件。
我尝试了以下方法,但得到的却是文本,它得到了密钥
我在 component.ts 中分配了一个带有标题的变量
import { TranslateService } from '@ngx-translate/core';
constructor(public translate: TranslateService,) {
}
public title= this.translate.instant('title-key');
在component.html中。我有这个变量作为参数函数
<a class="nav-link" (click)="functionName(title)" > {{'title-key' | translate}}</a>
应该发送的标题是tasks 而是发送密钥 -> title-key
functionName(tabSelected) {
switch(tabSelected) {
case this.title:
this.tab = true;
break;
default:
}
}
<kendo-tabstrip #tabstrip [keepTabContent]="true">
<kendo-tabstrip-tab [title] = "title" *ngIf="tab" [selected]="true">
<ng-template kendoTabContent *loadOnDemand>
<app-component></app-component>
</ng-template>
</kendo-tabstrip-tab>
<kendo-tabstrip>
【问题讨论】:
-
对不起,我没有达到你的目标。你想达到什么目标?请描述工作流程。您只想在 UI 中显示一些翻译吗?
-
@Lynx242 是的,我正在尝试显示所选语言的选项卡。请查看已编辑的问题。
标签: angular internationalization i18next angular-translate