From 9112fb64ed609850d088a826226c1ea00bbdaa4d Mon Sep 17 00:00:00 2001
From: 4gray
Date: Sat, 20 Feb 2021 11:52:21 +0100
Subject: [PATCH] refactor: finalize localization
---
.vscode/settings.json | 3 +-
.../channel-list-container.component.html | 48 +++++++++++++------
.../channel-list-container.component.spec.ts | 2 +
.../epg-list/epg-list.component.html | 23 ++++-----
.../epg-list/epg-list.component.spec.ts | 14 +++++-
.../html-video-player.component.spec.ts | 17 +++++--
.../video-player/video-player.component.html | 6 +--
src/app/settings/settings.component.ts | 18 +++++--
src/app/settings/settings.module.ts | 2 +-
src/assets/i18n/en.json | 31 +++++++++++-
10 files changed, 120 insertions(+), 44 deletions(-)
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 7ac9ce92e..303d337b2 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,3 +1,4 @@
{
- "i18n-ally.localesPaths": "src/assets/i18n"
+ "i18n-ally.localesPaths": "src/assets/i18n",
+ "i18n-ally.keystyle": "nested"
}
\ No newline at end of file
diff --git a/src/app/player/components/channel-list-container/channel-list-container.component.html b/src/app/player/components/channel-list-container/channel-list-container.component.html
index 8149042c2..7c88e1070 100644
--- a/src/app/player/components/channel-list-container/channel-list-container.component.html
+++ b/src/app/player/components/channel-list-container/channel-list-container.component.html
@@ -1,17 +1,21 @@
-
+
@@ -29,7 +33,10 @@
(click)="selectChannel(channel)"
>
- {{ i + 1 + '. ' + channel?.name || 'Unnamed Channel' }}
+ {{
+ i + 1 + '. ' + channel?.name ||
+ ('CHANNELS.UNNAMED_CHANNEL' | translate)
+ }}
@@ -37,7 +44,7 @@
-
+
@@ -45,9 +52,11 @@
0"
>
- {{ groups.key || 'Ungrouped' | titlecase }} ({{
- groups.value.length
- }})
+ {{
+ groups.key || ('CHANNELS.UNGROUPED' | translate)
+ | titlecase
+ }}
+ ({{ groups.value.length }})
{{
i + 1 + '. ' + channel?.name ||
- 'Unnamed Channel'
+ ('CHANNELS.UNNAMED_CHANNEL'
+ | translate)
}}
@@ -70,7 +80,7 @@
-
+
- {{ i + 1 + '. ' + channel?.name || 'Unnamed Channel' }}
+ {{
+ i + 1 + '. ' + channel?.name ||
+ ('CHANNELS.UNNAMED_CHANNEL' | translate)
+ }}
diff --git a/src/app/player/components/channel-list-container/channel-list-container.component.spec.ts b/src/app/player/components/channel-list-container/channel-list-container.component.spec.ts
index a1ee6a696..da68a6e2d 100644
--- a/src/app/player/components/channel-list-container/channel-list-container.component.spec.ts
+++ b/src/app/player/components/channel-list-container/channel-list-container.component.spec.ts
@@ -1,3 +1,4 @@
+import { MatTooltipModule } from '@angular/material/tooltip';
import { TranslatePipe } from '@ngx-translate/core';
/* eslint-disable @typescript-eslint/unbound-method */
import { ComponentFixture, TestBed } from '@angular/core/testing';
@@ -48,6 +49,7 @@ describe('ChannelListContainerComponent', () => {
MockModule(MatListModule),
MockModule(ScrollingModule),
MockModule(MatTabsModule),
+ MockModule(MatTooltipModule),
MockModule(MatExpansionModule),
FormsModule,
RouterTestingModule,
diff --git a/src/app/player/components/epg-list/epg-list.component.html b/src/app/player/components/epg-list/epg-list.component.html
index df3570557..1f3faea56 100644
--- a/src/app/player/components/epg-list/epg-list.component.html
+++ b/src/app/player/components/epg-list/epg-list.component.html
@@ -15,7 +15,9 @@
{{
- playingNow ? playingNow.title[0]?.value : 'Live stream'
+ playingNow
+ ? playingNow.title[0]?.value
+ : ('EPG.LIVE_STREAM' | translate)
}}
@@ -25,7 +27,7 @@
fxFlex="40px"
mat-icon-button
(click)="changeDate('prev')"
- matTooltip="Previous day"
+ [matTooltip]="'EPG.PREVIOUS_DAY' | translate"
>
chevron_left
@@ -40,7 +42,7 @@
fxFlex="40px"
mat-icon-button
(click)="changeDate('next')"
- matTooltip="Next day"
+ [matTooltip]="'EPG.NEXT_DAY' | translate"
>
chevron_right
@@ -82,7 +84,7 @@
= item.start && timeNow <= item.stop"
class="live badge"
- matTooltip="Live now"
+ [matTooltip]="'EPG.LIVE_NOW' | translate"
>live
timeshiftUntil
"
class="rec badge"
- matTooltip="Timeshift is available, click to play"
+ [matTooltip]="'EPG.TIMESHIFT_AVAILABLE' | translate"
>r
@@ -101,10 +103,9 @@
- Ooops, EPG is not available for the selected
- date
+ {{
+ 'EPG.EPG_NOT_AVAILABLE_DATE' | translate
+ }}
@@ -112,8 +113,8 @@
- Ooops, EPG is not available for this channel.
- Please add/change the url of EPG list the settings of the app.
+ {{ 'EPG.EPG_NOT_AVAILABLE_CHANNEL_TITLE' | translate }}
+ {{ 'EPG.EPG_NOT_AVAILABLE_CHANNEL_DESCRIPTION' | translate }}
diff --git a/src/app/player/components/epg-list/epg-list.component.spec.ts b/src/app/player/components/epg-list/epg-list.component.spec.ts
index 850886093..e7a955ba7 100644
--- a/src/app/player/components/epg-list/epg-list.component.spec.ts
+++ b/src/app/player/components/epg-list/epg-list.component.spec.ts
@@ -1,3 +1,5 @@
+import { TranslatePipe } from '@ngx-translate/core';
+import { MatTooltipModule } from '@angular/material/tooltip';
/* eslint-disable @typescript-eslint/unbound-method */
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { EpgListComponent, EpgData } from './epg-list.component';
@@ -84,8 +86,16 @@ describe('EpgListComponent', () => {
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
- declarations: [EpgListComponent, MockPipe(MomentDatePipe)],
- imports: [MockModule(MatIconModule), MockModule(MatListModule)],
+ declarations: [
+ EpgListComponent,
+ MockPipe(MomentDatePipe),
+ MockPipe(TranslatePipe),
+ ],
+ imports: [
+ MockModule(MatIconModule),
+ MockModule(MatTooltipModule),
+ MockModule(MatListModule),
+ ],
providers: [
{ provide: ElectronService, useClass: ElectronServiceStub },
],
diff --git a/src/app/player/components/html-video-player/html-video-player.component.spec.ts b/src/app/player/components/html-video-player/html-video-player.component.spec.ts
index 7323acd06..8e5fd6570 100644
--- a/src/app/player/components/html-video-player/html-video-player.component.spec.ts
+++ b/src/app/player/components/html-video-player/html-video-player.component.spec.ts
@@ -1,3 +1,5 @@
+import { MockPipe } from 'ng-mocks';
+import { TranslatePipe } from '@ngx-translate/core';
/* eslint-disable @typescript-eslint/unbound-method */
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { SimpleChange } from '@angular/core';
@@ -16,11 +18,16 @@ describe('HtmlVideoPlayerComponent', () => {
},
};
- beforeEach(waitForAsync(() => {
- TestBed.configureTestingModule({
- declarations: [HtmlVideoPlayerComponent],
- }).compileComponents();
- }));
+ beforeEach(
+ waitForAsync(() => {
+ TestBed.configureTestingModule({
+ declarations: [
+ HtmlVideoPlayerComponent,
+ MockPipe(TranslatePipe),
+ ],
+ }).compileComponents();
+ })
+ );
beforeEach(() => {
fixture = TestBed.createComponent(HtmlVideoPlayerComponent);
diff --git a/src/app/player/components/video-player/video-player.component.html b/src/app/player/components/video-player/video-player.component.html
index 090ad2395..5d76a99a0 100644
--- a/src/app/player/components/video-player/video-player.component.html
+++ b/src/app/player/components/video-player/video-player.component.html
@@ -20,14 +20,14 @@
diff --git a/src/app/settings/settings.component.ts b/src/app/settings/settings.component.ts
index beb33b712..9d4022517 100644
--- a/src/app/settings/settings.component.ts
+++ b/src/app/settings/settings.component.ts
@@ -1,3 +1,4 @@
+import { TranslateService } from '@ngx-translate/core';
import { Component, OnInit, OnDestroy } from '@angular/core';
import { FormGroup, FormBuilder } from '@angular/forms';
import { StorageMap } from '@ngx-pwa/local-storage';
@@ -28,11 +29,11 @@ export class SettingsComponent implements OnInit, OnDestroy {
players = [
{
id: 'html5',
- label: ' HTML5 Video Player',
+ label: 'HTML5 Video Player',
},
{
id: 'videojs',
- label: ' VideoJs Player',
+ label: 'VideoJs Player',
},
];
@@ -67,7 +68,8 @@ export class SettingsComponent implements OnInit, OnDestroy {
private http: HttpClient,
private router: Router,
private snackBar: MatSnackBar,
- private storage: StorageMap
+ private storage: StorageMap,
+ private translate: TranslateService
) {
this.settingsForm = this.formBuilder.group({
player: ['videojs'], // default value
@@ -85,9 +87,15 @@ export class SettingsComponent implements OnInit, OnDestroy {
);
if (isOutdated) {
- this.updateMessage = `There is a new version available: ${response.version}`;
+ this.updateMessage = `${
+ this.translate.instant(
+ 'SETTINGS.NEW_VERSION_AVAILABLE'
+ ) as string
+ }: ${response.version}`;
} else {
- this.updateMessage = 'You are using the latest version';
+ this.updateMessage = this.translate.instant(
+ 'SETTINGS.LATEST_VERSION'
+ );
}
})
);
diff --git a/src/app/settings/settings.module.ts b/src/app/settings/settings.module.ts
index f2eb22359..98afb58c8 100644
--- a/src/app/settings/settings.module.ts
+++ b/src/app/settings/settings.module.ts
@@ -2,7 +2,7 @@ import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { SettingsComponent } from './settings.component';
import { SettingsRoutingModule } from './settings.routing';
-import { SharedModule } from 'app/shared/shared.module';
+import { SharedModule } from '../shared/shared.module';
@NgModule({
imports: [CommonModule, SettingsRoutingModule, SharedModule],
diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json
index f6299b247..2e4aa7504 100644
--- a/src/assets/i18n/en.json
+++ b/src/assets/i18n/en.json
@@ -46,6 +46,35 @@
"VIDEO_PLAYER_PLACEHOLDER": "Select an option",
"VERSION": "Version",
"SAVE_CHANGES": "Save changes",
- "BACK_TO_HOME": "Back to home"
+ "BACK_TO_HOME": "Back to home",
+ "NEW_VERSION_AVAILABLE": "There is a new version available",
+ "LATEST_VERSION": "You are using the latest version"
+ },
+ "CHANNELS": {
+ "SEARCH_CHANNEL": "Search channel",
+ "UPLOAD_OR_SELECT_OTHER_PLAYLIST": "Upload or select other playlist",
+ "ALL_CHANNELS": "All channels",
+ "GROUPS": "Groups",
+ "UNGROUPED": "Ungrouped",
+ "UNNAMED_CHANNEL": "Unnamed Channel",
+ "FAVORITES": "Favorites",
+ "NO_FAVORITES": "No favorites yet",
+ "USE_STAR_TO_FAVORITE": "Please use the 'star' icon to add channels to this list.",
+ "REMOVE_FAVORITE": "Remove from favorites"
+ },
+ "TOP_MENU": {
+ "OPEN_CHANNELS_LIST": "Open channels list",
+ "TOGGLE_FAVORITE_FLAG": "Toggle favorite flag",
+ "OPEN_EPG_LIST": "Open EPG list"
+ },
+ "EPG": {
+ "NEXT_DAY": "Next day",
+ "PREVIOUS_DAY": "Previous day",
+ "LIVE_NOW": "Live now",
+ "LIVE_STREAM": "Live stream",
+ "TIMESHIFT_AVAILABLE": "Timeshift is available, click to play",
+ "EPG_NOT_AVAILABLE_DATE": "Ooops, EPG is not available for the selected date",
+ "EPG_NOT_AVAILABLE_CHANNEL_TITLE": "Ooops, EPG is not available for this channel.",
+ "EPG_NOT_AVAILABLE_CHANNEL_DESCRIPTION": "Please add/change the url of EPG list the settings of the app."
}
}
\ No newline at end of file