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

Update 8 files #8

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion apps/demo/src/assets/i18n/it.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"M_HOME": "Home",
"M_ABOUT": "Info",
"M_SETTINGS": "Opzioni"
"M_SETTINGS": "Opzioni",
"L_LANGUAGE": "test"
}
3 changes: 3 additions & 0 deletions libs/core/src/i18n/en.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const en = {
'L_LANGUAGE' : 'Language'
}
3 changes: 3 additions & 0 deletions libs/core/src/i18n/it.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const it = {
'L_LANGUAGE' : 'Lingua'
}
14 changes: 12 additions & 2 deletions libs/core/src/lib/components/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Component, Input, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { SioCoreAppComponentState } from './store/app.state';

import { it } from '../../../i18n/it';
import { en } from '../../../i18n/en';

//import { E_SIDEMENU } from '../menu/menu.enum';
import { Select } from '@ngxs/store';
import { Observable, Subject } from 'rxjs';
Expand Down Expand Up @@ -56,7 +59,7 @@ export class SioCoreAppComponent implements OnInit, OnDestroy {
ionRouterOutlet!: IonRouterOutlet;

public position: 'side' | 'bottom' | 'top' = 'bottom';

constructor(
public sioCoreAppComponentState: SioCoreAppComponentState,
private platform: Platform,
Expand All @@ -70,6 +73,8 @@ export class SioCoreAppComponent implements OnInit, OnDestroy {
this.sioCoreAppComponentState.LoadConfig(
this.sioCoreEnvironmentService.config.app
); } else this.sioCoreLoggerService.warn('[sioCoreAppComponent][Constructor] No config in environment file');
this.translateService.setTranslation('it', it, true);
this.translateService.setTranslation('en', en, true);
}

//@Select(SioCoreAppComponentState.split)
Expand All @@ -79,7 +84,12 @@ export class SioCoreAppComponent implements OnInit, OnDestroy {
(async () => {
this.sioCoreLoggerService.info('await for platform avaible...');
let platform = await this.platform.ready();
this.translateService.addLangs(this.sioCoreEnvironmentService.config.app.language.avaibles);

this.translateService.setTranslation('it', it, true);
this.translateService.setTranslation('en', en, true);

//this.translateService.addLangs(this.sioCoreEnvironmentService.config.app.language.avaibles);
this.translateService.use(this.sioCoreEnvironmentService.config.app.language.default);
this.sioCoreLoggerService.info('Check platform...');
switch (platform) {
case 'dom':
Expand Down
1 change: 1 addition & 0 deletions libs/core/src/lib/components/app/app.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ export interface SioCoreAppCompomentInterface {
}
| undefined;
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<ion-item>
<ion-select [label]="this.label" (ionChange)="this.onChange($event)">
<ion-select label="{{ this.label | translate }}" (ionChange)="this.onChange($event)">
<ion-select-option value="it">Italiano</ion-select-option>
<ion-select-option value="en">Inglese</ion-select-option>
</ion-select>
</ion-item>
</ion-item>
{{ this.label | translate }}
12 changes: 11 additions & 1 deletion libs/core/src/lib/modules/common.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { NgxsFormPluginModule } from '@ngxs/form-plugin';
import { SioCoreComponents } from '../components';
import { HttpClientModule } from '@angular/common/http';
import { RouterModule } from '@angular/router';
import { createTranslateLoader } from './core.module';

export function create2TranslateLoader(http: HttpClient) {
console.log('pippo load');
Expand All @@ -33,7 +34,16 @@ export function create2TranslateLoader(http: HttpClient) {
RouterModule,
ReactiveFormsModule,
IonicModule,
TranslateModule,
TranslateModule.forChild(
{
'extend' : true,
'loader': {
'provide': TranslateLoader,
'useFactory': createTranslateLoader,
'deps': [HttpClient],
},
}
),
NgxsFormPluginModule,
],
exports: [...SioCoreComponents, IonicModule, TranslateModule ],
Expand Down
10 changes: 1 addition & 9 deletions libs/core/src/lib/modules/core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,7 @@ export function createTranslateLoader(http: HttpClient) {
imports: [
CommonModule,
HttpClientModule,
TranslateModule.forRoot({
'defaultLanguage': 'it',
'loader': {
'provide': TranslateLoader,
'useFactory': createTranslateLoader,
'deps': [HttpClient],
},
'parser': { provide: TranslateParser, useClass: NgxTranslateDebugParser },
}),
TranslateModule.forRoot(),
LoggerModule.forRoot(),
FormsModule,
ReactiveFormsModule,
Expand Down