使用:this.translocoService.translate('object.test');时如何设置作用域?
我的翻译文件位于类似于" MyFolder“的文件夹中,因此范围将是MyFolder。
这是我的*.json文件的结构:
{
"demo": "test123",
"object" : {
"test" : "My.Test"
}
}这是我喜欢做的事情:
export class AppComponent {
constructor(private translocoService: TranslocoService,@Inject(TRANSLOCO_SCOPE) private scope) {}
ngOnInit() {
this.translocoService.translate('object.test'); //How to set the scope here?
}
}发布于 2021-07-23 13:25:26
解决方案:
export class AppComponent {
constructor(private translocoService: TranslocoService,@Inject(TRANSLOCO_SCOPE) private scope) {}
ngOnInit() {
var testLable = this.translocoService.translate(this.scope + '.object.test');
}
}https://stackoverflow.com/questions/68485593
复制相似问题