mirror of
https://framagit.org/framasoft/framadate/funky-framadate-front.git
synced 2023-08-25 13:53:14 +02:00
auto set lang from local storage service
This commit is contained in:
parent
2956ef0167
commit
d181578893
@ -1,4 +1,5 @@
|
||||
# Internationalisation - i18n
|
||||
## Dans les templates HTML
|
||||
Toutes les chaînes de texte doivent être disponible en minimum deux langues: Français et Anglais.
|
||||
|
||||
Pour l'ajout de nouvelles traductions voir [la documentations des traductions.md](../traductions.md)
|
||||
@ -15,4 +16,5 @@ Faites en sorte de réutiliser au maximum les phrases identiques.
|
||||
|
||||
## Traduction de la documentation mkdocs
|
||||
|
||||
voir ici https://www.mkdocs.org/user-guide/configuration/#lang
|
||||
Pour traduire cette documentation (les fichiers markdwon dans le dossier /docs/) qui génère un mini site avec mkdocs avec la commande de build, il faut faire des fichiers avec un nom de langue tels que index.fr.md et index.en.md.
|
||||
Plus d'infos: https://www.mkdocs.org/user-guide/configuration/#lang
|
||||
|
@ -34,9 +34,10 @@ import { AdministrationModule } from './features/administration/administration.m
|
||||
import localeEn from '@angular/common/locales/en';
|
||||
import localeFr from '@angular/common/locales/fr';
|
||||
import localeEs from '@angular/common/locales/es';
|
||||
// code for locale are listed by the ISO-639
|
||||
registerLocaleData(localeFr, 'fr-FR');
|
||||
registerLocaleData(localeEn, 'en-EN');
|
||||
registerLocaleData(localeEs, 'es-ES');
|
||||
registerLocaleData(localeEs, 'ca-ES');
|
||||
|
||||
export class MyMissingTranslationHandler implements MissingTranslationHandler {
|
||||
public handle(params: MissingTranslationHandlerParams): string {
|
||||
@ -45,7 +46,7 @@ export class MyMissingTranslationHandler implements MissingTranslationHandler {
|
||||
}
|
||||
|
||||
export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader {
|
||||
return new TranslateHttpLoader(http);
|
||||
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
|
@ -17,6 +17,7 @@
|
||||
</span>
|
||||
</button>
|
||||
</label>
|
||||
({{ availableLanguages.length }} availableLanguages)
|
||||
<select class="is-hidden" id="lang_selector" (change)="setLang()" [(ngModel)]="currentLang">
|
||||
<option *ngFor="let language of availableLanguages" value="{{ language }}">
|
||||
<!-- {{ language }} - -->
|
||||
|
@ -11,7 +11,7 @@ import { StorageService } from '../../../../core/services/storage.service';
|
||||
})
|
||||
export class LanguageSelectorComponent implements OnInit {
|
||||
public currentLang: Language;
|
||||
public availableLanguages: any = [];
|
||||
public availableLanguages: any = ['FR', 'EN', 'ES'];
|
||||
language: string;
|
||||
|
||||
constructor(private languageService: LanguageService, private storageService: StorageService) {}
|
||||
@ -19,11 +19,16 @@ export class LanguageSelectorComponent implements OnInit {
|
||||
ngOnInit(): void {
|
||||
this.availableLanguages = this.languageService.getAvailableLanguages();
|
||||
|
||||
console.log('this.availableLanguages', this.availableLanguages);
|
||||
this.currentLang = this.languageService.getLangage();
|
||||
if (this.storageService.language && this.availableLanguages.indexOf(this.storageService.language) !== -1) {
|
||||
this.languageService.setLanguage(this.storageService.language);
|
||||
}
|
||||
}
|
||||
|
||||
setLang(): void {
|
||||
this.languageService.setLanguage(this.currentLang);
|
||||
this.storageService.language = this.currentLang;
|
||||
}
|
||||
|
||||
nextLang(): void {
|
||||
|
Loading…
Reference in New Issue
Block a user