translate calendar elements from app init

This commit is contained in:
Tykayn 2021-11-08 10:26:16 +01:00 committed by tykayn
parent c67f309180
commit a438bdff6c
5 changed files with 109 additions and 38 deletions

View File

@ -13,6 +13,8 @@ import { ShortcutEventOutput, ShortcutInput } from 'ng-keyboard-shortcuts';
import { PollService } from './core/services/poll.service'; import { PollService } from './core/services/poll.service';
import { Poll } from './core/models/poll.model'; import { Poll } from './core/models/poll.model';
import { PollDTO } from './core/models/poll.DTO.model'; import { PollDTO } from './core/models/poll.DTO.model';
import { PrimeNGConfig } from 'primeng/api';
import { Language } from './core/enums/language.enum';
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
@ -37,6 +39,7 @@ export class AppComponent implements OnInit, OnDestroy, AfterViewInit {
private titleService: Title, private titleService: Title,
private themeService: ThemeService, private themeService: ThemeService,
private pollService: PollService, private pollService: PollService,
private config: PrimeNGConfig,
private languageService: LanguageService // private mockingService: MockingService private languageService: LanguageService // private mockingService: MockingService
) {} ) {}
@ -51,6 +54,10 @@ export class AppComponent implements OnInit, OnDestroy, AfterViewInit {
} }
ngOnInit(): void { ngOnInit(): void {
this.languageService.getPrimeNgStrings().subscribe((resp) => {
this.config.setTranslation(resp);
});
this.printpath('', this.router.config); this.printpath('', this.router.config);
this.router.events.subscribe((evt) => { this.router.events.subscribe((evt) => {
if (!(evt instanceof NavigationEnd)) { if (!(evt instanceof NavigationEnd)) {

View File

@ -37,6 +37,10 @@ export class LanguageService {
this.setLanguageOnInit(); this.setLanguageOnInit();
} }
public getPrimeNgStrings() {
return this.translate.get('calendar_widget');
}
private setLanguageOnInit(): void { private setLanguageOnInit(): void {
// set language from storage // set language from storage
if (!this.translate.currentLang) { if (!this.translate.currentLang) {

View File

@ -74,12 +74,17 @@
selectionMode="multiple" selectionMode="multiple"
inputId="multiple" inputId="multiple"
showButtonBar="true" showButtonBar="true"
[locale]="'calendar_widget' | translate"
[inline]="true" [inline]="true"
[showWeek]="true" [showWeek]="true"
></p-calendar> ></p-calendar>
</div> </div>
<div class="day-time">
<app-time-list></app-time-list>
</div>
<div class="debug"> <div class="debug">
<pre>{{ pollService.calendar | json }}</pre> <pre>{{ pollService.calendar | json }}</pre>
<pre>{{ 'calendar_widget' | translate }}</pre>
</div> </div>
</div> </div>
</div> </div>

View File

@ -144,7 +144,7 @@
"selectors": { "selectors": {
"lang": "Sélectionner la langue" "lang": "Sélectionner la langue"
}, },
"validation" : { "validation": {
"You must enter a value": "You must enter a EEEE" "You must enter a value": "You must enter a EEEE"
}, },
"You must enter a value": "You must enter a valueeeeeeee", "You must enter a value": "You must enter a valueeeeeeee",
@ -576,8 +576,7 @@
"the-administrator-locked-this-poll-votes-and-comments-are-frozen-it-is-no-longer-possible-to-partici": "L'administrateur·rice a verrouillé ce sondage. Les votes et commentaires sont gelés, il n'est plus possible de participer", "the-administrator-locked-this-poll-votes-and-comments-are-frozen-it-is-no-longer-possible-to-partici": "L'administrateur·rice a verrouillé ce sondage. Les votes et commentaires sont gelés, il n'est plus possible de participer",
"the-poll-has-expired-it-will-soon-be-deleted": "Le sondage a expiré, il sera bientôt supprimé.", "the-poll-has-expired-it-will-soon-be-deleted": "Le sondage a expiré, il sera bientôt supprimé.",
"your-vote-has-been-saved-but-please-note-you-need-to-keep-this-personalised-link-to-be-able-to-edit-": "Votre vote a bien été pris en compte, mais faites attention : ce sondage n'autorise l'édition de votre vote qu'avec le lien personnalisé suivant ; conservez-le précieusement !" "your-vote-has-been-saved-but-please-note-you-need-to-keep-this-personalised-link-to-be-able-to-edit-": "Votre vote a bien été pris en compte, mais faites attention : ce sondage n'autorise l'édition de votre vote qu'avec le lien personnalisé suivant ; conservez-le précieusement !"
} },
,
"LANGUAGES": { "LANGUAGES": {
"DE": "Allemand", "DE": "Allemand",
"FR": "Français", "FR": "Français",
@ -593,7 +592,7 @@
"OC": "oc", "OC": "oc",
"SV": "sv" "SV": "sv"
}, },
"calendar_widget" : { "calendar_widget": {
"startsWith": "Starts with", "startsWith": "Starts with",
"contains": "Contains", "contains": "Contains",
"notContains": "Not contains", "notContains": "Not contains",
@ -620,12 +619,62 @@
"choose": "Choose", "choose": "Choose",
"upload": "Upload", "upload": "Upload",
"cancel": "Cancel", "cancel": "Cancel",
"dayNames": ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], "dayNames": [
"dayNamesShort": ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], "Sunday",
"dayNamesMin": ["Su","Mo","Tu","We","Th","Fr","Sa"], "Monday",
"monthNames": ["Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre"], "Tuesday",
"monthNamesShort": ["Jan", "Feb", "Mar", "Apr", "May", "Jun","Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], "Wednesday",
"Thursday",
"Friday",
"Saturday"
],
"dayNamesShort": [
"Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat"
],
"dayNamesMin": [
"Su",
"Mo",
"Tu",
"We",
"Th",
"Fr",
"Sa"
],
"monthNames": [
"Janvier",
"Février",
"Mars",
"Avril",
"Mai",
"Juin",
"Juillet",
"Août",
"Septembre",
"Octobre",
"Novembre",
"Décembre"
],
"monthNamesShort": [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
],
"today": "Aujourd'hui", "today": "Aujourd'hui",
"weekHeader": "Wk" "weekHeader": "Wk"
} }
} }

View File

@ -241,6 +241,12 @@ mat-checkbox {
border: solix 1px $logo_color; border: solix 1px $logo_color;
margin: 1em auto; margin: 1em auto;
.pi-chevron-left:after {
content: '<';
}
.pi-chevron-right:after {
content: '>';
}
.p-datepicker-month { .p-datepicker-month {
margin-right: 1em; margin-right: 1em;
} }