Implement auto RTL support for i18n locales like Arabic, Persian, etc.
Fixes #255
This commit is contained in:
parent
ea521651fd
commit
e49ecd9368
@ -1,4 +1,4 @@
|
||||
import { Component, HostListener, OnInit } from '@angular/core';
|
||||
import { Component, HostListener, OnInit, Inject, LOCALE_ID, HostBinding } from '@angular/core';
|
||||
import { Router, NavigationEnd } from '@angular/router';
|
||||
import { WebsocketService } from '../../services/websocket.service';
|
||||
import { StateService } from 'src/app/services/state.service';
|
||||
@ -15,7 +15,14 @@ export class AppComponent implements OnInit {
|
||||
public router: Router,
|
||||
private websocketService: WebsocketService,
|
||||
private stateService: StateService,
|
||||
) { }
|
||||
@Inject(LOCALE_ID) private locale: string,
|
||||
) {
|
||||
if (this.locale.startsWith('ar') || this.locale.startsWith('fa')) {
|
||||
this.dir = 'rtl';
|
||||
}
|
||||
}
|
||||
|
||||
@HostBinding('attr.dir') dir = 'ltr';
|
||||
|
||||
@HostListener('document:keydown', ['$event'])
|
||||
handleKeyboardEvents(event: KeyboardEvent) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user