From cc7b4661eefc6674e4e5b849b3b6cda2eb67bbe7 Mon Sep 17 00:00:00 2001 From: Baptiste Lemoine Date: Fri, 27 Sep 2019 16:10:03 +0200 Subject: [PATCH 01/16] :alien: demo for i18n --- package.json | 91 ++++++------ src/app/app.component.html | 6 +- src/app/app.component.ts | 12 +- src/locale/messages.fr.xlf | 0 messages.xlf => src/locale/messages.xlf | 187 ++++++++++++++---------- 5 files changed, 164 insertions(+), 132 deletions(-) delete mode 100644 src/locale/messages.fr.xlf rename messages.xlf => src/locale/messages.xlf (72%) diff --git a/package.json b/package.json index a8ccedcd..9fe668c6 100644 --- a/package.json +++ b/package.json @@ -1,47 +1,48 @@ { - "name": "framadate", - "version": "0.0.0", - "scripts": { - "ng": "ng", - "start": "ng serve", - "build": "ng build", - "test": "ng test", - "lint": "ng lint", - "e2e": "ng e2e" - }, - "private": true, - "dependencies": { - "@angular/animations": "~8.2.0", - "@angular/common": "~8.2.0", - "@angular/compiler": "~8.2.0", - "@angular/core": "~8.2.0", - "@angular/forms": "~8.2.0", - "@angular/platform-browser": "~8.2.0", - "@angular/platform-browser-dynamic": "~8.2.0", - "@angular/router": "~8.2.0", - "rxjs": "~6.4.0", - "tslib": "^1.10.0", - "zone.js": "~0.9.1" - }, - "devDependencies": { - "@angular-devkit/build-angular": "~0.802.1", - "@angular/cli": "~8.2.1", - "@angular/compiler-cli": "~8.2.0", - "@angular/language-service": "~8.2.0", - "@types/node": "~8.9.4", - "@types/jasmine": "~3.3.8", - "@types/jasminewd2": "~2.0.3", - "codelyzer": "^5.0.0", - "jasmine-core": "~3.4.0", - "jasmine-spec-reporter": "~4.2.1", - "karma": "~4.1.0", - "karma-chrome-launcher": "~2.2.0", - "karma-coverage-istanbul-reporter": "~2.0.1", - "karma-jasmine": "~2.0.1", - "karma-jasmine-html-reporter": "^1.4.0", - "protractor": "~5.4.0", - "ts-node": "~7.0.0", - "tslint": "~5.15.0", - "typescript": "~3.5.3" - } + "name": "framadate-funky-frontend", + "version": "0.1.0", + "scripts": { + "ng": "ng", + "start": "ng serve", + "build": "ng build", + "test": "ng test", + "lint": "ng lint", + "e2e": "ng e2e", + "trans": "ng xi18n --output-path=src/locale --i18n-locale=fr" + }, + "private": true, + "dependencies": { + "@angular/animations": "~8.2.0", + "@angular/common": "~8.2.0", + "@angular/compiler": "~8.2.0", + "@angular/core": "~8.2.0", + "@angular/forms": "~8.2.0", + "@angular/platform-browser": "~8.2.0", + "@angular/platform-browser-dynamic": "~8.2.0", + "@angular/router": "~8.2.0", + "rxjs": "~6.4.0", + "tslib": "^1.10.0", + "zone.js": "~0.9.1" + }, + "devDependencies": { + "@angular-devkit/build-angular": "~0.802.1", + "@angular/cli": "~8.2.1", + "@angular/compiler-cli": "~8.2.0", + "@angular/language-service": "~8.2.0", + "@types/node": "~8.9.4", + "@types/jasmine": "~3.3.8", + "@types/jasminewd2": "~2.0.3", + "codelyzer": "^5.0.0", + "jasmine-core": "~3.4.0", + "jasmine-spec-reporter": "~4.2.1", + "karma": "~4.1.0", + "karma-chrome-launcher": "~2.2.0", + "karma-coverage-istanbul-reporter": "~2.0.1", + "karma-jasmine": "~2.0.1", + "karma-jasmine-html-reporter": "^1.4.0", + "protractor": "~5.4.0", + "ts-node": "~7.0.0", + "tslint": "~5.15.0", + "typescript": "~3.5.3" + } } diff --git a/src/app/app.component.html b/src/app/app.component.html index 8e697f5e..66e4ce31 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -4,9 +4,13 @@ Frama date - + Ceci est une démo + + Updated {minutes, plural, =0 {just now} =1 {one minute ago} other {{{minutes}} minutes ago}} + + diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 701853e3..7a6f834f 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,10 +1,12 @@ -import { Component } from '@angular/core'; +import {Component} from '@angular/core'; @Component({ - selector: 'app-root', - templateUrl: './app.component.html', - styleUrls: ['./app.component.scss'] + selector: 'app-root', + templateUrl: './app.component.html', + styleUrls: ['./app.component.scss'] }) export class AppComponent { - title = 'framadate'; + title = 'framadate'; + //translation demo: + minutes = 12; } diff --git a/src/locale/messages.fr.xlf b/src/locale/messages.fr.xlf deleted file mode 100644 index e69de29b..00000000 diff --git a/messages.xlf b/src/locale/messages.xlf similarity index 72% rename from messages.xlf rename to src/locale/messages.xlf index b0cfa003..ba35cf85 100644 --- a/messages.xlf +++ b/src/locale/messages.xlf @@ -1,59 +1,39 @@ - + - + - Ceci est une démo - + Ceci est une démo + src/app/app.component.html 7 + introduction header saying just demo + demo title - + - Pour commencer - + Updated + - src/app/form-container/form-container.component.html - 4 - - - - - Je veux créer un sondage - - - src/app/form-container/form-container.component.html + src/app/app.component.html 10 - - - Dont le titre sera - + + {VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other { minutes ago} } - src/app/form-container/form-container.component.html - 34 + src/app/app.component.html + 11 - - - et la description serait - + + placeholder à traduire - src/app/form-container/form-container.component.html - 64 - - - - - Continuer - - - src/app/form-container/form-container.component.html - 82 + src/app/app.component.html + 13 @@ -75,9 +55,9 @@ 10 - + - Config spécialement pour les dates + Config spécialement pour les dates src/app/pages/dates/dates.component.html @@ -102,9 +82,9 @@ 20 - + - Ajouter une plage de dates + Ajouter une plage de dates src/app/pages/dates/dates.component.html @@ -120,10 +100,10 @@ 35 - + - infos de debug - + infos de debug + src/app/debugger/debugger.component.html 4 @@ -156,90 +136,90 @@ 51 - + - Envoyer le formulaire + Envoyer le formulaire src/app/debugger/debugger.component.html 64 - + - Visibilité des réponses + Visibilité des réponses src/app/pages/visibility/visibility.component.html 1 - + - Votes + Votes src/app/pages/visibility/visibility.component.html 4 - + - Archivage + Archivage src/app/pages/visibility/visibility.component.html 7 - + - Accès au sondage + Accès au sondage src/app/pages/visibility/visibility.component.html 11 - + - Résumé avant validation + Résumé avant validation src/app/pages/resume/resume.component.html 1 - + - Images + Images src/app/pages/pictures/pictures.component.html - 1 + 2 - + - Choisir les propositions - + Choisir les propositions + src/app/pages/answers/answers.component.html 2 - + - vous pouvez utiliser la syntaxe markdown - + vous pouvez utiliser la syntaxe markdown + src/app/pages/answers/answers.component.html 6 - + - Et c'est tout pour nous! + Et c'est tout pour nous! src/app/pages/end-confirmation/end-confirmation.component.html @@ -267,20 +247,20 @@ 6 - + - Créer un sondage - + Créer un sondage + src/app/pages/create-or-retrieve/create-or-retrieve.component.html 2 - + - Planifiez des rendez-vous avec vos amis ou votre famille ou créez un sondage avec du texte, des images ou des - liens… un sondage quoi ! - + Planifiez des rendez-vous avec vos amis ou votre famille ou créez un sondage avec du texte, des images ou des + liens… un sondage quoi ! + src/app/pages/create-or-retrieve/create-or-retrieve.component.html 8 @@ -295,24 +275,69 @@ 19 - + - Où sont mes sondages ? - + Où sont mes sondages ? + src/app/pages/create-or-retrieve/create-or-retrieve.component.html 29 - + - Je cherche les sondages qui correspondent à mon mail : - + Je cherche les sondages qui correspondent à mon mail : + src/app/pages/create-or-retrieve/create-or-retrieve.component.html 40 + + + Pour commencer + + + src/app/pages/home/home.component.html + 4 + + + + + Je veux créer un sondage + + + src/app/pages/home/home.component.html + 10 + + + + + Dont le titre sera + + + src/app/pages/home/home.component.html + 34 + + + + + et la description serait + + + src/app/pages/home/home.component.html + 64 + + + + + Continuer + + + src/app/pages/home/home.component.html + 82 + + From d1ced70b1b81e2fa7cf8124bc9d6ee9cd76eeae5 Mon Sep 17 00:00:00 2001 From: Baptiste Lemoine Date: Tue, 1 Oct 2019 15:43:37 +0200 Subject: [PATCH 02/16] :alien: add ngx translate config --- package-lock.json | 26 +++++++-- package.json | 2 + src/app/app.component.html | 10 ++++ src/app/app.component.ts | 14 +++++ src/app/app.module.ts | 109 +++++++++++++++++++++---------------- src/assets/i18n/en.json | 7 +++ src/assets/i18n/fr.json | 7 +++ 7 files changed, 122 insertions(+), 53 deletions(-) create mode 100644 src/assets/i18n/en.json create mode 100644 src/assets/i18n/fr.json diff --git a/package-lock.json b/package-lock.json index 061e13ed..f8c49d2e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { - "name": "framadate", - "version": "0.0.0", + "name": "framadate-funky-frontend", + "version": "0.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1192,6 +1192,22 @@ "webpack-sources": "1.3.0" } }, + "@ngx-translate/core": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/@ngx-translate/core/-/core-11.0.1.tgz", + "integrity": "sha512-nBCa1ZD9fAUY/3eskP3Lql2fNg8OMrYIej1/5GRsfcutx9tG/5fZLCv9m6UCw1aS+u4uK/vXjv1ctG/FdMvaWg==", + "requires": { + "tslib": "^1.9.0" + } + }, + "@ngx-translate/http-loader": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@ngx-translate/http-loader/-/http-loader-4.0.0.tgz", + "integrity": "sha512-x8LumqydWD7eX9yQTAVeoCM9gFUIGVTUjZqbxdAUavAA3qVnk9wCQux7iHLPXpydl8vyQmLoPQR+fFU+DUDOMA==", + "requires": { + "tslib": "^1.9.0" + } + }, "@schematics/angular": { "version": "8.2.1", "resolved": "https://registry.npmjs.org/@schematics/angular/-/angular-8.2.1.tgz", @@ -4310,9 +4326,9 @@ "dev": true }, "handlebars": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.1.2.tgz", - "integrity": "sha512-nvfrjqvt9xQ8Z/w0ijewdD/vvWDTOweBUm96NTr66Wfvo1mJenBLwcYmPs3TIBP5ruzYGD7Hx/DaM9RmhroGPw==", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.4.0.tgz", + "integrity": "sha512-xkRtOt3/3DzTKMOt3xahj2M/EqNhY988T+imYSlMgs5fVhLN2fmKVVj0LtEGmb+3UUYV5Qmm1052Mm3dIQxOvw==", "dev": true, "requires": { "neo-async": "^2.6.0", diff --git a/package.json b/package.json index 9fe668c6..c11a46c6 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,8 @@ "@angular/platform-browser": "~8.2.0", "@angular/platform-browser-dynamic": "~8.2.0", "@angular/router": "~8.2.0", + "@ngx-translate/core": "^11.0.1", + "@ngx-translate/http-loader": "^4.0.0", "rxjs": "~6.4.0", "tslib": "^1.10.0", "zone.js": "~0.9.1" diff --git a/src/app/app.component.html b/src/app/app.component.html index 66e4ce31..25abf861 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -19,3 +19,13 @@ +
+
+ + +
+

Title

+
+ {{ 'Intro' | translate:user }} +
+
diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 7a6f834f..32109cdf 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,4 +1,5 @@ import {Component} from '@angular/core'; +import {TranslateService} from "@ngx-translate/core"; @Component({ selector: 'app-root', @@ -9,4 +10,17 @@ export class AppComponent { title = 'framadate'; //translation demo: minutes = 12; + user = { + name: 'Arthur', + age: 42 + }; + + constructor(private translate: TranslateService) { + this.translate.setDefaultLang('fr'); + } + + switchLanguage(language: string) { + this.translate.use(language); + } + } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 2f51ec2e..abda2087 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -10,59 +10,72 @@ import {FormsModule} from '@angular/forms'; import {NavigationComponent} from './ui/navigation/navigation.component'; import {RouterModule} from '@angular/router'; import {Routes} from './config/Routes'; -import {CommonModule} from '@angular/common'; -import { DatesComponent } from './pages/dates/dates.component'; -import { DebuggerComponent } from './debugger/debugger.component'; -import { VisibilityComponent } from './pages/visibility/visibility.component'; -import { ResumeComponent } from './pages/resume/resume.component'; -import { PicturesComponent } from './pages/pictures/pictures.component'; -import { AnswersComponent } from './pages/answers/answers.component'; -import { EndConfirmationComponent } from './pages/end-confirmation/end-confirmation.component'; -import { CreateOrRetrieveComponent } from './pages/create-or-retrieve/create-or-retrieve.component'; -import { CalendarComponent } from './calendar/calendar.component'; - -import { registerLocaleData } from '@angular/common'; +import {CommonModule, registerLocaleData} from '@angular/common'; +import {DatesComponent} from './pages/dates/dates.component'; +import {DebuggerComponent} from './debugger/debugger.component'; +import {VisibilityComponent} from './pages/visibility/visibility.component'; +import {ResumeComponent} from './pages/resume/resume.component'; +import {PicturesComponent} from './pages/pictures/pictures.component'; +import {AnswersComponent} from './pages/answers/answers.component'; +import {EndConfirmationComponent} from './pages/end-confirmation/end-confirmation.component'; +import {CreateOrRetrieveComponent} from './pages/create-or-retrieve/create-or-retrieve.component'; +import {CalendarComponent} from './calendar/calendar.component'; import localeFr from '@angular/common/locales/fr'; -import { VotingSummaryComponent } from './pages/voting-summary/voting-summary.component'; -import { VotingGraphComponent } from './pages/voting-graph/voting-graph.component'; -import { VotingChoiceComponent } from './pages/voting-choice/voting-choice.component'; -import { PasswordComponent } from './pages/password/password.component'; -import { HomeComponent } from './pages/home/home.component'; +import {VotingSummaryComponent} from './pages/voting-summary/voting-summary.component'; +import {VotingGraphComponent} from './pages/voting-graph/voting-graph.component'; +import {VotingChoiceComponent} from './pages/voting-choice/voting-choice.component'; +import {PasswordComponent} from './pages/password/password.component'; +import {HomeComponent} from './pages/home/home.component'; +import {HttpClient, HttpClientModule} from '@angular/common/http'; +import {TranslateLoader, TranslateModule, TranslateService} from '@ngx-translate/core'; +import {TranslateHttpLoader} from '@ngx-translate/http-loader'; registerLocaleData(localeFr, 'fr'); -@NgModule({ - declarations: [ - AppComponent, - BaseComponent, - KindComponent, - HeaderComponent, - NavigationComponent, - DatesComponent, - DebuggerComponent, - VisibilityComponent, - ResumeComponent, - PicturesComponent, - AnswersComponent, - EndConfirmationComponent, - CreateOrRetrieveComponent, - CalendarComponent, - VotingSummaryComponent, - VotingGraphComponent, - VotingChoiceComponent, - PasswordComponent, - HomeComponent, +export function HttpLoaderFactory(http: HttpClient) { + return new TranslateHttpLoader(http); +} - ], - imports: [ - CommonModule, - BrowserModule, - AppRoutingModule, - FormsModule, - RouterModule.forRoot(Routes) - ], - providers: [], - bootstrap: [AppComponent] +@NgModule({ + declarations: [ + AppComponent, + BaseComponent, + KindComponent, + HeaderComponent, + NavigationComponent, + DatesComponent, + DebuggerComponent, + VisibilityComponent, + ResumeComponent, + PicturesComponent, + AnswersComponent, + EndConfirmationComponent, + CreateOrRetrieveComponent, + CalendarComponent, + VotingSummaryComponent, + VotingGraphComponent, + VotingChoiceComponent, + PasswordComponent, + HomeComponent, + + ], + imports: [ + CommonModule, + BrowserModule, + AppRoutingModule, + TranslateModule.forRoot({ + loader: { + provide: TranslateLoader, + useFactory: HttpLoaderFactory, + deps: [HttpClient] + } + }), + HttpClientModule, + FormsModule, + RouterModule.forRoot(Routes) + ], + providers: [TranslateService], + bootstrap: [AppComponent] }) export class AppModule { } diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json new file mode 100644 index 00000000..281c06de --- /dev/null +++ b/src/assets/i18n/en.json @@ -0,0 +1,7 @@ +{ + "Title": "Translation example", + "Intro": "Hello I am {{name}}, I am {{age}} years old.", + "home": { + "title": "home's title" + } +} diff --git a/src/assets/i18n/fr.json b/src/assets/i18n/fr.json new file mode 100644 index 00000000..9f4cae39 --- /dev/null +++ b/src/assets/i18n/fr.json @@ -0,0 +1,7 @@ +{ + "Title": "Example de traduction", + "Intro": "Bonjour je m'appelle {{name}}, j'ai {{age}} ans.", + "home": { + "title": "le titre de la home" + } +} From 90323c28c7e96d1d3c70e54b8818d34680fc5783 Mon Sep 17 00:00:00 2001 From: Baptiste Lemoine Date: Tue, 1 Oct 2019 16:34:11 +0200 Subject: [PATCH 03/16] :alien: json strings to translate things in en/fr --- src/app/app.component.html | 3 ++ src/assets/i18n/en.json | 57 ++++++++++++++++++++++++++++++++++++++ src/assets/i18n/fr.json | 57 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+) diff --git a/src/app/app.component.html b/src/app/app.component.html index 25abf861..f32b5d75 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -7,6 +7,9 @@ Ceci est une démo + + {{"config.demo"|translate}} + Updated {minutes, plural, =0 {just now} =1 {one minute ago} other {{{minutes}} minutes ago}} diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 281c06de..38f3c40e 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -3,5 +3,62 @@ "Intro": "Hello I am {{name}}, I am {{age}} years old.", "home": { "title": "home's title" + }, + "config": { + "demo": "this is a demo", + "demo_other": "this is an other demo", + "continue": "Continuer", + "perfect": "C'est parfait", + "title": "Créer un sondage", + "letsgo": "C'est parti'", + "description": "Planifiez des rendez-vous avec vos amis ou votre famille ou créez un sondage avec du texte, des images ou des liens… un sondage quoi !", + "find_my_polls": "Où sont mes sondages ?", + "find_helper": "Je cherche les sondages qui correspondent à mon mail", + "find_button": "Retrouver mes sondages" + }, + "creation": { + "title": "Pour commencer ", + "want": "Je veux créer un sondage", + "kind": { + "classic": "classique", + "date": "spécial dates" + }, + "choose_title": "Dont le titre sera", + "choose_title_placeholder": "titre", + "name": "Je peux aussi préciser mon nom si je le souhaite", + "name_placeholder": "mon nom", + "description": "et la description serait", + "description_placeholder": "description" + }, + "dates": { + "title": "Config spécialement pour les dates ", + "hours_different": "Je souhaite mettre des créneaux horaires pour chaque journée", + "multiple": { + "identical": "identiques", + "different": "possiblement différentes" + }, + "add": "Ajouter une plage de dates", + "count_dates": "choix de dates" + }, + "choices": { + "title": "Choisir les propositions", + "helper": "vous pouvez utiliser la syntaxe markdown ", + "answer_preset_1": "réponse de démo 1", + "answer_preset_2": "réponse 2", + "answer_preset_3": "la réponse D", + "add": "Ajouter", + "continue": "Voyons ce que ça donne" + }, + "resume": { + "title": "Et c'est tout pour nous!", + "admins": "Coté administrateur-ice-eux", + "users": "Coté sondés", + "links_mail": "recevoir les liens par e-mail" + }, + "visibility": { + "title": "Visibilité des réponses", + "votes": "Votes", + "archiving": "Archivage", + "access": "Accès au sondage" } } diff --git a/src/assets/i18n/fr.json b/src/assets/i18n/fr.json index 9f4cae39..5dd7f533 100644 --- a/src/assets/i18n/fr.json +++ b/src/assets/i18n/fr.json @@ -3,5 +3,62 @@ "Intro": "Bonjour je m'appelle {{name}}, j'ai {{age}} ans.", "home": { "title": "le titre de la home" + }, + "config": { + "demo": "C'est une démo traduite en Français", + "demo_other": "C'est une autre démo traduite en Français", + "continue": "Continuer", + "perfect": "C'est parfait", + "title": "Créer un sondage", + "letsgo": "C'est parti'", + "description": "Planifiez des rendez-vous avec vos amis ou votre famille ou créez un sondage avec du texte, des images ou des liens… un sondage quoi !", + "find_my_polls": "Où sont mes sondages ?", + "find_helper": "Je cherche les sondages qui correspondent à mon mail", + "find_button": "Retrouver mes sondages" + }, + "creation": { + "title": "Pour commencer ", + "want": "Je veux créer un sondage", + "kind": { + "classic": "classique", + "date": "spécial dates" + }, + "choose_title": "Dont le titre sera", + "choose_title_placeholder": "titre", + "name": "Je peux aussi préciser mon nom si je le souhaite", + "name_placeholder": "mon nom", + "description": "et la description serait", + "description_placeholder": "description" + }, + "dates": { + "title": "Config spécialement pour les dates ", + "hours_different": "Je souhaite mettre des créneaux horaires pour chaque journée", + "multiple": { + "identical": "identiques", + "different": "possiblement différentes" + }, + "add": "Ajouter une plage de dates", + "count_dates": "choix de dates" + }, + "choices": { + "title": "Choisir les propositions", + "helper": "vous pouvez utiliser la syntaxe markdown ", + "answer_preset_1": "réponse de démo 1", + "answer_preset_2": "réponse 2", + "answer_preset_3": "la réponse D", + "add": "Ajouter", + "continue": "Voyons ce que ça donne" + }, + "resume": { + "title": "Et c'est tout pour nous!", + "admins": "Coté administrateur-ice-eux", + "users": "Coté sondés", + "links_mail": "recevoir les liens par e-mail" + }, + "visibility": { + "title": "Visibilité des réponses", + "votes": "Votes", + "archiving": "Archivage", + "access": "Accès au sondage" } } From 91101f2326413f9d63476c026c0207f93cb3e490 Mon Sep 17 00:00:00 2001 From: Baptiste Lemoine Date: Tue, 1 Oct 2019 16:39:29 +0200 Subject: [PATCH 04/16] :alien: add missing translation support --- src/app/app.module.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index abda2087..5feaf6f2 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -27,9 +27,21 @@ import {VotingChoiceComponent} from './pages/voting-choice/voting-choice.compone import {PasswordComponent} from './pages/password/password.component'; import {HomeComponent} from './pages/home/home.component'; import {HttpClient, HttpClientModule} from '@angular/common/http'; -import {TranslateLoader, TranslateModule, TranslateService} from '@ngx-translate/core'; +import { + MissingTranslationHandler, + MissingTranslationHandlerParams, + TranslateLoader, + TranslateModule, + TranslateService +} from '@ngx-translate/core'; import {TranslateHttpLoader} from '@ngx-translate/http-loader'; +export class MyMissingTranslationHandler implements MissingTranslationHandler { + handle(params: MissingTranslationHandlerParams) { + return 'some value'; + } +} + registerLocaleData(localeFr, 'fr'); export function HttpLoaderFactory(http: HttpClient) { @@ -64,6 +76,11 @@ export function HttpLoaderFactory(http: HttpClient) { BrowserModule, AppRoutingModule, TranslateModule.forRoot({ + missingTranslationHandler: { + provide: MissingTranslationHandler, + useClass: MyMissingTranslationHandler, + }, + useDefaultLang: false, loader: { provide: TranslateLoader, useFactory: HttpLoaderFactory, From 0f2a72f8720220fd17db37006b5361b425975006 Mon Sep 17 00:00:00 2001 From: Baptiste Lemoine Date: Tue, 1 Oct 2019 16:52:36 +0200 Subject: [PATCH 05/16] :alien: translate 2 first pages --- src/app/app.component.html | 31 ++++++---------- src/app/app.module.ts | 4 ++- src/app/debugger/debugger.component.html | 36 ++----------------- src/app/pages/base-page/base.component.html | 4 ++- .../create-or-retrieve.component.html | 18 +++++----- src/app/pages/home/home.component.html | 14 ++++---- src/assets/i18n/en.json | 34 +++++++++--------- 7 files changed, 52 insertions(+), 89 deletions(-) diff --git a/src/app/app.component.html b/src/app/app.component.html index f32b5d75..fba0c0fa 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -4,17 +4,18 @@ Frama date - - Ceci est une démo - - - {{"config.demo"|translate}} - - - Updated {minutes, plural, =0 {just now} =1 {one minute ago} other {{{minutes}} minutes ago}} - - + +
+
+ + +
+

Title

+
+ {{ 'Intro' | translate:user }} +
+
@@ -22,13 +23,3 @@ -
-
- - -
-

Title

-
- {{ 'Intro' | translate:user }} -
-
diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 5feaf6f2..6f6a2080 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -21,6 +21,7 @@ import {EndConfirmationComponent} from './pages/end-confirmation/end-confirmatio import {CreateOrRetrieveComponent} from './pages/create-or-retrieve/create-or-retrieve.component'; import {CalendarComponent} from './calendar/calendar.component'; import localeFr from '@angular/common/locales/fr'; +import localeEn from '@angular/common/locales/en'; import {VotingSummaryComponent} from './pages/voting-summary/voting-summary.component'; import {VotingGraphComponent} from './pages/voting-graph/voting-graph.component'; import {VotingChoiceComponent} from './pages/voting-choice/voting-choice.component'; @@ -43,6 +44,7 @@ export class MyMissingTranslationHandler implements MissingTranslationHandler { } registerLocaleData(localeFr, 'fr'); +registerLocaleData(localeEn, 'en'); export function HttpLoaderFactory(http: HttpClient) { return new TranslateHttpLoader(http); @@ -80,7 +82,7 @@ export function HttpLoaderFactory(http: HttpClient) { provide: MissingTranslationHandler, useClass: MyMissingTranslationHandler, }, - useDefaultLang: false, + // useDefaultLang: false, loader: { provide: TranslateLoader, useFactory: HttpLoaderFactory, diff --git a/src/app/debugger/debugger.component.html b/src/app/debugger/debugger.component.html index 5b504209..7ebaa11c 100644 --- a/src/app/debugger/debugger.component.html +++ b/src/app/debugger/debugger.component.html @@ -4,6 +4,9 @@

infos de debug

+ + {{"config.demo"|translate}} +
  • @@ -24,39 +27,6 @@
- - Choix cornélien syncronisé: - - - - - C'est parfait!