mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-11 02:46:16 -08:00
feat: add internationalization
This commit is contained in:
7 files changed
+69
-8
No files matched your search
@@ -101,6 +101,7 @@ export class AppComponent {
|
|||||||
Object.keys(settings).length > 0 &&
|
Object.keys(settings).length > 0 &&
|
||||||
settings.epgUrl
|
settings.epgUrl
|
||||||
) {
|
) {
|
||||||
|
this.translate.setDefaultLang(settings.language ?? 'en');
|
||||||
this.electronService.ipcRenderer.send(EPG_FETCH, {
|
this.electronService.ipcRenderer.send(EPG_FETCH, {
|
||||||
url: settings.epgUrl,
|
url: settings.epgUrl,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
/**
|
||||||
|
* Enum with all languages that are available in the application
|
||||||
|
*/
|
||||||
|
export enum Language {
|
||||||
|
ENGLISH = 'en',
|
||||||
|
}
|
||||||
@@ -67,6 +67,34 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</mat-list-item>
|
</mat-list-item>
|
||||||
|
<mat-list-item>
|
||||||
|
<div matLine fxLayout="row">
|
||||||
|
<p fxFlex>
|
||||||
|
{{ 'SETTINGS.LANGUAGE' | translate }}
|
||||||
|
</p>
|
||||||
|
<p fxFlex fxLayoutAlign="start center">
|
||||||
|
<mat-form-field appearance="fill">
|
||||||
|
<mat-label>{{
|
||||||
|
'SETTINGS.VIDEO_PLAYER_PLACEHOLDER'
|
||||||
|
| translate
|
||||||
|
}}</mat-label>
|
||||||
|
<mat-select formControlName="language">
|
||||||
|
<mat-option
|
||||||
|
*ngFor="
|
||||||
|
let language of languageEnum
|
||||||
|
| keyvalue
|
||||||
|
"
|
||||||
|
[value]="language.value"
|
||||||
|
>{{
|
||||||
|
'LANGUAGES.' + language.key
|
||||||
|
| translate
|
||||||
|
}}</mat-option
|
||||||
|
>
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</mat-list-item>
|
||||||
<mat-list-item>
|
<mat-list-item>
|
||||||
<div matLine fxLayout="row">
|
<div matLine fxLayout="row">
|
||||||
<p fxFlex>{{ 'SETTINGS.VERSION' | translate }}</p>
|
<p fxFlex>{{ 'SETTINGS.VERSION' | translate }}</p>
|
||||||
|
|||||||
@@ -7,6 +7,12 @@ button {
|
|||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
}
|
}
|
||||||
|
|
||||||
::ng-deep .mat-card {
|
::ng-deep{
|
||||||
border-radius: 0 !important;
|
.mat-card {
|
||||||
|
border-radius: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mat-list-item {
|
||||||
|
height: 70px !important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,11 @@ import * as semver from 'semver';
|
|||||||
import { ElectronService } from '../services/electron.service';
|
import { ElectronService } from '../services/electron.service';
|
||||||
import { ChannelQuery } from '../state';
|
import { ChannelQuery } from '../state';
|
||||||
import { EPG_FETCH } from '../../../ipc-commands';
|
import { EPG_FETCH } from '../../../ipc-commands';
|
||||||
|
import { Language } from './language.enum';
|
||||||
|
|
||||||
|
/** Url of the package.json file in the app repository, required to get the version of the released app */
|
||||||
|
const PACKAGE_JSON_URL =
|
||||||
|
'https://raw.githubusercontent.com/4gray/iptvnator/master/package.json';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-settings',
|
selector: 'app-settings',
|
||||||
@@ -21,9 +26,8 @@ export class SettingsComponent implements OnInit, OnDestroy {
|
|||||||
/** Subscription object */
|
/** Subscription object */
|
||||||
private subscription: Subscription = new Subscription();
|
private subscription: Subscription = new Subscription();
|
||||||
|
|
||||||
/** Url of the package.json file in the app repository, required to get the version of the released app */
|
/** List with available languages as enum */
|
||||||
latestPackageJsonUrl =
|
languageEnum = Language;
|
||||||
'https://raw.githubusercontent.com/4gray/iptvnator/master/package.json';
|
|
||||||
|
|
||||||
/** Player options */
|
/** Player options */
|
||||||
players = [
|
players = [
|
||||||
@@ -72,13 +76,14 @@ export class SettingsComponent implements OnInit, OnDestroy {
|
|||||||
private translate: TranslateService
|
private translate: TranslateService
|
||||||
) {
|
) {
|
||||||
this.settingsForm = this.formBuilder.group({
|
this.settingsForm = this.formBuilder.group({
|
||||||
player: ['videojs'], // default value
|
player: ['videojs'],
|
||||||
epgUrl: '',
|
epgUrl: '',
|
||||||
|
language: Language.ENGLISH,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.subscription.add(
|
this.subscription.add(
|
||||||
this.http
|
this.http
|
||||||
.get(this.latestPackageJsonUrl)
|
.get(PACKAGE_JSON_URL)
|
||||||
.subscribe((response: { version: string }) => {
|
.subscribe((response: { version: string }) => {
|
||||||
this.version = this.electronService.getAppVersion();
|
this.version = this.electronService.getAppVersion();
|
||||||
const isOutdated = semver.lt(
|
const isOutdated = semver.lt(
|
||||||
@@ -111,6 +116,9 @@ export class SettingsComponent implements OnInit, OnDestroy {
|
|||||||
this.settingsForm.setValue({
|
this.settingsForm.setValue({
|
||||||
player: settings.player ? settings.player : 'videojs',
|
player: settings.player ? settings.player : 'videojs',
|
||||||
epgUrl: settings.epgUrl ? settings.epgUrl : '',
|
epgUrl: settings.epgUrl ? settings.epgUrl : '',
|
||||||
|
language: settings.language
|
||||||
|
? settings.language
|
||||||
|
: Language.ENGLISH,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -137,6 +145,9 @@ export class SettingsComponent implements OnInit, OnDestroy {
|
|||||||
if (this.settingsForm.value.epgUrl) {
|
if (this.settingsForm.value.epgUrl) {
|
||||||
this.fetchEpg();
|
this.fetchEpg();
|
||||||
}
|
}
|
||||||
|
this.translate.setDefaultLang(
|
||||||
|
this.settingsForm.value.language
|
||||||
|
);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { Language } from './language.enum';
|
||||||
|
|
||||||
export type VideoPlayerType = 'html5' | 'videojs';
|
export type VideoPlayerType = 'html5' | 'videojs';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -6,4 +8,5 @@ export type VideoPlayerType = 'html5' | 'videojs';
|
|||||||
export interface Settings {
|
export interface Settings {
|
||||||
player: VideoPlayerType;
|
player: VideoPlayerType;
|
||||||
epgUrl: string;
|
epgUrl: string;
|
||||||
|
language: Language;
|
||||||
}
|
}
|
||||||
@@ -48,7 +48,8 @@
|
|||||||
"SAVE_CHANGES": "Save changes",
|
"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",
|
"NEW_VERSION_AVAILABLE": "There is a new version available",
|
||||||
"LATEST_VERSION": "You are using the latest version"
|
"LATEST_VERSION": "You are using the latest version",
|
||||||
|
"LANGUAGE": "Language"
|
||||||
},
|
},
|
||||||
"CHANNELS": {
|
"CHANNELS": {
|
||||||
"SEARCH_CHANNEL": "Search channel",
|
"SEARCH_CHANNEL": "Search channel",
|
||||||
@@ -76,5 +77,10 @@
|
|||||||
"EPG_NOT_AVAILABLE_DATE": "Ooops, EPG is not available for the selected date",
|
"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_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."
|
"EPG_NOT_AVAILABLE_CHANNEL_DESCRIPTION": "Please add/change the url of EPG list the settings of the app."
|
||||||
|
},
|
||||||
|
"LANGUAGES": {
|
||||||
|
"ENGLISH": "English",
|
||||||
|
"RUSSIAN": "Russian",
|
||||||
|
"GERMAN": "German"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user