Skip to content

Commit

Permalink
ADMIN: Fix translation
Browse files Browse the repository at this point in the history
* BETTER: Fix translation

Signed-off-by: Bertrand Zuchuat <[email protected]>
  • Loading branch information
Garfield-fr committed Dec 20, 2018
1 parent f417ce6 commit ba635f1
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 17 deletions.
36 changes: 29 additions & 7 deletions ui/admin/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,38 @@
]
},
"configurations": {
"preprod": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "none",
"sourceMap": false,
"extractCss": false,
"namedChunks": false,
"aot": true,
"extractLicenses": false,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
},
"proxy": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"aot": false,
"i18nLocale": "fr"
"aot": false
},
"production": {
"fileReplacements": [
Expand All @@ -70,7 +93,6 @@
"maximumError": "5mb"
}
],
"i18nLocale": "en",
"deployUrl": "/static/js/rero_ils/admin/",
"outputPath": "../../rero_ils/static/js/rero_ils/admin"
}
Expand All @@ -86,15 +108,15 @@
"browserTarget": "admin:build:proxy",
"proxyConfig": "proxy.conf.json"
},
"preprod": {
"browserTarget": "admin:build:proxy",
"proxyConfig": "proxy.conf.json"
},
"production": {
"browserTarget": "admin:build:production"
},
"fr": {
"browserTarget": "admin:build:fr"
},
"proxy": {
"browserTarget": "admin:build:proxy",
"proxyConfig": "proxy.conf.json"
}
}
},
Expand Down
1 change: 1 addition & 0 deletions ui/admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"e2e": "ng e2e",
"deploy": "ng build --configuration=production",
"proxy": "ng serve --configuration=proxy",
"preprod": "ng serve --configuration=preprod",
"extract_messages": "ngx-translate-extract -i ./src -o ./src/assets/i18n/en*.json -m _; key2value.py ./src/assets/i18n/en_US.json; key2value.py ./src/assets/i18n/en.json",
"update_catalog": "ngx-translate-extract -i ./src -o ./src/assets/i18n/{it,de,en,fr}.json -m _"
},
Expand Down
18 changes: 13 additions & 5 deletions ui/admin/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BrowserModule } from '@angular/platform-browser';
import { registerLocaleData } from '@angular/common';
import { NgModule, LOCALE_ID } from '@angular/core';
import { HttpClientModule, HttpClient } from '@angular/common/http';
import { BsLocaleService } from 'ngx-bootstrap/datepicker';
Expand All @@ -9,12 +10,18 @@ import { ModalModule } from 'ngx-bootstrap/modal';
import { environment } from '../environments/environment';
import { defineLocale } from 'ngx-bootstrap/chronos';
import { deLocale, enGbLocale, frLocale, itLocale } from 'ngx-bootstrap/locale';
import localeDe from '@angular/common/locales/de';
import localeEn from '@angular/common/locales/en';
import localeFr from '@angular/common/locales/fr';
import localeIt from '@angular/common/locales/it';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';

import { MylibraryComponent } from './mylibrary/mylibrary.component';
import { UserService } from './user.service';



export function HttpLoaderFactory(http: HttpClient) {
let assets_prefix = '/';
if (environment.production) {
Expand Down Expand Up @@ -64,10 +71,10 @@ export function HttpLoaderFactory(http: HttpClient) {
})
export class AppModule {
languages = {
'de': deLocale,
'en': enGbLocale,
'fr': frLocale,
'it': itLocale
'de': { ngx: deLocale, angular: localeDe },
'en': { ngx: enGbLocale, angular: localeEn },
'fr': { ngx: frLocale, angular: localeFr },
'it': { ngx: itLocale, angular: localeIt }
};

constructor(
Expand All @@ -76,7 +83,8 @@ export class AppModule {
) {
translate.setDefaultLang('en');
for (const [key, value] of Object.entries(this.languages)) {
defineLocale(key, value);
defineLocale(key, value.ngx);
registerLocaleData(value.angular, key);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, Input, Inject, LOCALE_ID } from '@angular/core';
import { Component, OnInit, Input } from '@angular/core';
import { BsModalService, BsModalRef } from 'ngx-bootstrap/modal';
import { ExceptionDatesEditComponent } from '../exception-dates-edit/exception-dates-edit.component';

Expand All @@ -13,10 +13,7 @@ export class ExceptionDatesListComponent implements OnInit {

@Input() library;

constructor(
private modalService: BsModalService,
@Inject(LOCALE_ID) locale: string
) { }
constructor(private modalService: BsModalService) { }

ngOnInit() {
}
Expand Down

0 comments on commit ba635f1

Please sign in to comment.