📅  最后修改于: 2022-03-11 15:01:26.837000             🧑  作者: Mango
import { Component } from '@angular/core';
import { TranslateService, LangChangeEvent } from '@ngx-translate/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
textDir: string = 'ltr';
constructor(private translate: TranslateService) {
//this is to determine the text direction depending on the selected language
this.translate.onLangChange.subscribe((event: LangChangeEvent) =>
{
if(event.lang == 'ar')
{
this.textDir = 'rtl';
}
else
{
this.textDir = 'ltr';
}
});
}
}