Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate date when language change #7191

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coderNadir Investigate the origin of this warn message and eliminate it.

image

)

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