Skip to content

Commit

Permalink
Merge pull request #7191 from ever-co/feat/#7175-translate-date
Browse files Browse the repository at this point in the history
Translate date when language change
  • Loading branch information
rahul-rocket authored Nov 28, 2023
2 parents 5d01e40 + 13d56e5 commit e9389d9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions apps/gauzy/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { AfterViewInit, Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute, NavigationEnd } from '@angular/router';
import { SeoService } from './@core/utils/seo.service';
import { TranslateService } from '@ngx-translate/core';
import { LangChangeEvent, TranslateService } from '@ngx-translate/core';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { IDateRangePicker, ILanguage, LanguagesEnum } from '@gauzy/contracts';
import { isNotEmpty } from '@gauzy/common-angular';
Expand All @@ -26,6 +26,7 @@ import {
import { environment } from '../environments/environment';
import { JitsuService } from './@core/services/analytics/jitsu.service';
import { union } from 'underscore';
import { moment } from './@core/moment-extend';

@UntilDestroy({ checkProperties: true })
@Component({
Expand Down Expand Up @@ -59,14 +60,19 @@ export class AppComponent implements OnInit, AfterViewInit {
this.jitsuService.trackPageViews();
this.seoService.trackCanonicalChanges();

// -- Translate date when language change
this.translate.onLangChange.subscribe(
(langChangeEvent: LangChangeEvent) => moment.locale(langChangeEvent.lang)
)

this.store.systemLanguages$
.pipe(untilDestroyed(this))
.subscribe((languages) => {
//Returns the language code name from the browser, e.g. "en", "bg", "he", "ru"
const browserLang = this.translate.getBrowserLang();

//Gets default enum languages, e.g. "en", "bg", "he", "ru"
const defaultLanguages = Object.values(LanguagesEnum);
const defaultLanguages: string[] = Object.values(LanguagesEnum);

//Gets system languages
let systemLanguages: string[] = _.pluck(languages, 'code');
Expand Down

0 comments on commit e9389d9

Please sign in to comment.