diff --git a/frontend/src/app/services/state.service.ts b/frontend/src/app/services/state.service.ts index 920f32dd9..9f7cc58a3 100644 --- a/frontend/src/app/services/state.service.ts +++ b/frontend/src/app/services/state.service.ts @@ -1,4 +1,4 @@ -import { Inject, Injectable, PLATFORM_ID } from '@angular/core'; +import { Inject, Injectable, PLATFORM_ID, LOCALE_ID } from '@angular/core'; import { ReplaySubject, BehaviorSubject, Subject, fromEvent, Observable } from 'rxjs'; import { Transaction } from '../interfaces/electrs.interface'; import { IBackendInfo, MempoolBlock, MempoolBlockWithTransactions, MempoolBlockDelta, MempoolInfo, Recommendedfees, ReplacedTransaction, TransactionStripped } from '../interfaces/websocket.interface'; @@ -113,6 +113,7 @@ export class StateService { constructor( @Inject(PLATFORM_ID) private platformId: any, + @Inject(LOCALE_ID) private locale: string, private router: Router, private storageService: StorageService, ) { @@ -151,7 +152,10 @@ export class StateService { this.blockVSize = this.env.BLOCK_WEIGHT_UNITS / 4; - this.timeLtr = new BehaviorSubject(this.storageService.getValue('time-preference-ltr') === 'true'); + const savedTimePreference = this.storageService.getValue('time-preference-ltr'); + const rtlLanguage = (this.locale.startsWith('ar') || this.locale.startsWith('fa') || this.locale.startsWith('he')); + // default time direction is right-to-left, unless locale is a RTL language + this.timeLtr = new BehaviorSubject(savedTimePreference === 'true' || (savedTimePreference == null && rtlLanguage)); this.timeLtr.subscribe((ltr) => { this.storageService.setValue('time-preference-ltr', ltr ? 'true' : 'false'); });