From edc22cc47b3e5dba47f4bb358c7389963557b8ed Mon Sep 17 00:00:00 2001 From: Isaac Abadi Date: Fri, 23 Oct 2020 01:38:44 -0400 Subject: [PATCH] File cards now use the locale to format dates --- .../custom-playlists.component.html | 2 +- .../recent-videos.component.html | 4 +-- .../unified-file-card.component.html | 2 +- .../unified-file-card.component.ts | 16 ++++++++++++ src/app/posts.services.ts | 13 ++++++++++ src/app/settings/locales_list.ts | 25 +++++++++++++------ src/app/settings/settings.component.ts | 2 +- 7 files changed, 52 insertions(+), 12 deletions(-) diff --git a/src/app/components/custom-playlists/custom-playlists.component.html b/src/app/components/custom-playlists/custom-playlists.component.html index 31d626f..90d2586 100644 --- a/src/app/components/custom-playlists/custom-playlists.component.html +++ b/src/app/components/custom-playlists/custom-playlists.component.html @@ -2,7 +2,7 @@
- +
diff --git a/src/app/components/recent-videos/recent-videos.component.html b/src/app/components/recent-videos/recent-videos.component.html index 5e99f20..258ff81 100644 --- a/src/app/components/recent-videos/recent-videos.component.html +++ b/src/app/components/recent-videos/recent-videos.component.html @@ -32,12 +32,12 @@
- +
- +
diff --git a/src/app/components/unified-file-card/unified-file-card.component.html b/src/app/components/unified-file-card/unified-file-card.component.html index 780bee4..a86206b 100644 --- a/src/app/components/unified-file-card/unified-file-card.component.html +++ b/src/app/components/unified-file-card/unified-file-card.component.html @@ -1,5 +1,5 @@
-
{{(file_obj.type === 'audio' || file_obj.isAudio) ? 'audiotrack' : 'movie'}}  {{file_obj.registered | date:'shortDate'}}
+
{{(file_obj.type === 'audio' || file_obj.isAudio) ? 'audiotrack' : 'movie'}}  {{file_obj.registered | date:'shortDate' : undefined : locale.ngID}}
(); @Output() goToSubscription = new EventEmitter(); @Output() deleteFile = new EventEmitter(); @Output() editPlaylist = new EventEmitter(); + @ViewChild(MatMenuTrigger) contextMenu: MatMenuTrigger; contextMenuPosition = { x: '0px', y: '0px' }; diff --git a/src/app/posts.services.ts b/src/app/posts.services.ts index 416fd2d..3336a7f 100644 --- a/src/app/posts.services.ts +++ b/src/app/posts.services.ts @@ -11,6 +11,7 @@ import { BehaviorSubject } from 'rxjs'; import { v4 as uuid } from 'uuid'; import { MatSnackBar } from '@angular/material/snack-bar'; import * as Fingerprint2 from 'fingerprintjs2'; +import { isoLangs } from './settings/locales_list'; @Injectable() export class PostsService implements CanActivate { @@ -53,6 +54,7 @@ export class PostsService implements CanActivate { config = null; subscriptions = null; sidenav = null; + locale = isoLangs['en']; constructor(private http: HttpClient, private router: Router, @Inject(DOCUMENT) private document: Document, public snackBar: MatSnackBar) { @@ -114,6 +116,17 @@ export class PostsService implements CanActivate { if (localStorage.getItem('card_size')) { this.card_size = localStorage.getItem('card_size'); } + + // localization + const locale = localStorage.getItem('locale'); + if (!locale) { + localStorage.setItem('locale', 'en'); + } + + if (isoLangs[locale]) { + this.locale = isoLangs[locale]; + } + } canActivate(route, state): Promise { return new Promise(resolve => { diff --git a/src/app/settings/locales_list.ts b/src/app/settings/locales_list.ts index d4531aa..5e88b73 100644 --- a/src/app/settings/locales_list.ts +++ b/src/app/settings/locales_list.ts @@ -122,7 +122,8 @@ export const isoLangs = { }, 'zh': { 'name': 'Chinese', - 'nativeName': '中文 (Zhōngwén), 汉语, 漢語' + 'nativeName': '中文 (Zhōngwén), 汉语, 漢語', + 'ngID': 'zh' }, 'cv': { 'name': 'Chuvash', @@ -162,8 +163,14 @@ export const isoLangs = { }, 'en': { 'name': 'English', - 'nativeName': 'English' - }, + 'nativeName': 'English', + 'ngID': 'en-US' + }, + 'en-GB': { + 'name': 'British English', + 'nativeName': 'British English', + 'ngID': 'en-GB' + }, 'eo': { 'name': 'Esperanto', 'nativeName': 'Esperanto' @@ -190,7 +197,8 @@ export const isoLangs = { }, 'fr': { 'name': 'French', - 'nativeName': 'français' + 'nativeName': 'français', + 'ngID': 'fr' }, 'ff': { 'name': 'Fula; Fulah; Pulaar; Pular', @@ -206,7 +214,8 @@ export const isoLangs = { }, 'de': { 'name': 'German', - 'nativeName': 'Deutsch' + 'nativeName': 'Deutsch', + 'ngID': 'de' }, 'el': { 'name': 'Greek, Modern', @@ -438,7 +447,8 @@ export const isoLangs = { }, 'nb': { 'name': 'Norwegian Bokmål', - 'nativeName': 'Norsk bokmål' + 'nativeName': 'Norsk bokmål', + 'ngID': 'nb' }, 'nd': { 'name': 'North Ndebele', @@ -594,7 +604,8 @@ export const isoLangs = { }, 'es': { 'name': 'Spanish; Castilian', - 'nativeName': 'español' + 'nativeName': 'español', + 'ngID': 'es' }, 'su': { 'name': 'Sundanese', diff --git a/src/app/settings/settings.component.ts b/src/app/settings/settings.component.ts index 37b14d0..9771251 100644 --- a/src/app/settings/settings.component.ts +++ b/src/app/settings/settings.component.ts @@ -17,7 +17,7 @@ import { ConfirmDialogComponent } from 'app/dialogs/confirm-dialog/confirm-dialo }) export class SettingsComponent implements OnInit { all_locales = isoLangs; - supported_locales = ['en', 'es', 'de', 'fr', 'zh', 'nb']; + supported_locales = ['en', 'es', 'de', 'fr', 'zh', 'nb', 'en-GB']; initialLocale = localStorage.getItem('locale'); initial_config = null;