mirror of
https://framagit.org/framasoft/framadate/funky-framadate-front.git
synced 2023-08-25 13:53:14 +02:00
add langs from framadate 1 in selector component
This commit is contained in:
parent
819e99f75e
commit
902c50d8cb
@ -1,12 +1,13 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
parser: '@typescript-eslint/parser',
|
parser: '@typescript-eslint/parser',
|
||||||
plugins: ['@typescript-eslint'],
|
plugins: ['@typescript-eslint', 'json'],
|
||||||
extends: [
|
extends: [
|
||||||
'eslint:recommended',
|
'eslint:recommended',
|
||||||
'plugin:@typescript-eslint/eslint-recommended',
|
'plugin:@typescript-eslint/eslint-recommended',
|
||||||
'plugin:@typescript-eslint/recommended',
|
'plugin:@typescript-eslint/recommended',
|
||||||
'plugin:prettier/recommended',
|
'plugin:prettier/recommended',
|
||||||
'prettier/@typescript-eslint',
|
'prettier/@typescript-eslint',
|
||||||
|
'plugin:json/recommended',
|
||||||
],
|
],
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
ecmaVersion: 2018,
|
ecmaVersion: 2018,
|
||||||
|
@ -6,15 +6,12 @@ import { environment } from '../environments/environment';
|
|||||||
import { Theme } from './core/enums/theme.enum';
|
import { Theme } from './core/enums/theme.enum';
|
||||||
import { LanguageService } from './core/services/language.service';
|
import { LanguageService } from './core/services/language.service';
|
||||||
import { ThemeService } from './core/services/theme.service';
|
import { ThemeService } from './core/services/theme.service';
|
||||||
import { NavigationEnd, Route, Router, RouterOutlet } from '@angular/router';
|
import { NavigationEnd, Route, Router } from '@angular/router';
|
||||||
import { slideInAnimation } from './shared/animations/main';
|
import { slideInAnimation } from './shared/animations/main';
|
||||||
import { FramaKeyboardShortcuts } from './shared/shortcuts/main';
|
import { FramaKeyboardShortcuts } from './shared/shortcuts/main';
|
||||||
import { ShortcutEventOutput, ShortcutInput } from 'ng-keyboard-shortcuts';
|
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 { PollDTO } from './core/models/poll.DTO.model';
|
|
||||||
import { PrimeNGConfig } from 'primeng/api';
|
import { PrimeNGConfig } from 'primeng/api';
|
||||||
import { Language } from './core/enums/language.enum';
|
|
||||||
import { ApiService } from './core/services/api.service';
|
import { ApiService } from './core/services/api.service';
|
||||||
import { DOCUMENT } from '@angular/common';
|
import { DOCUMENT } from '@angular/common';
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* liste des fichiers JSON de traduction des textes dans l'appli à charger par ngx-translate et prposer aux utilisateurs et utilisatrices de Framdate.
|
* liste des fichiers JSON de traduction des textes dans l'appli à charger par ngx-translate et prposer aux utilisateurs et utilisatrices de Framdate.
|
||||||
* Cette enum est utilisé dans le composant de sélection de langue.
|
* Cette enum est utilisé dans le composant de sélection de langue.
|
||||||
*/
|
*/
|
||||||
export enum Language {
|
export enum LanguageEnum {
|
||||||
FR = 'fr',
|
FR = 'fr',
|
||||||
BR = 'br',
|
BR = 'br',
|
||||||
CA = 'ca',
|
CA = 'ca',
|
||||||
|
@ -72,7 +72,7 @@ export class ApiService {
|
|||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
// mode: 'no-cors',
|
// mode: 'no-cors',
|
||||||
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
|
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
|
||||||
'Access-Control-Allow-Headers': 'Accept,Accept-Language,Content-Language,Content-Type',
|
'Access-Control-Allow-Headers': 'Accept,Accept-LanguageEnum,Content-LanguageEnum,Content-Type',
|
||||||
};
|
};
|
||||||
const headersAxios = {
|
const headersAxios = {
|
||||||
headers: headerDict,
|
headers: headerDict,
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { TranslateService, LangChangeEvent } from '@ngx-translate/core';
|
import { LangChangeEvent, TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
import { Language } from '../enums/language.enum';
|
import { LanguageEnum } from '../enums/language.enum';
|
||||||
import { StorageService } from './storage.service';
|
import { StorageService } from './storage.service';
|
||||||
import { type } from 'os';
|
|
||||||
import { isString } from 'util';
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
@ -12,11 +10,11 @@ import { isString } from 'util';
|
|||||||
export class LanguageService {
|
export class LanguageService {
|
||||||
constructor(private translate: TranslateService, private storageService: StorageService) {}
|
constructor(private translate: TranslateService, private storageService: StorageService) {}
|
||||||
|
|
||||||
public getLangage(): Language {
|
public getLangage(): LanguageEnum {
|
||||||
return this.translate.currentLang as Language;
|
return this.translate.currentLang as LanguageEnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
public setLanguage(language: Language): void {
|
public setLanguage(language: LanguageEnum): void {
|
||||||
this.translate.use(language.toString());
|
this.translate.use(language.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,11 +25,11 @@ export class LanguageService {
|
|||||||
public configureAndInitTranslations(): void {
|
public configureAndInitTranslations(): void {
|
||||||
// always save in storage the currentLang used
|
// always save in storage the currentLang used
|
||||||
this.translate.onLangChange.subscribe((event: LangChangeEvent) => {
|
this.translate.onLangChange.subscribe((event: LangChangeEvent) => {
|
||||||
this.storageService.language = event.lang as Language;
|
this.storageService.language = event.lang as LanguageEnum;
|
||||||
});
|
});
|
||||||
|
|
||||||
// set all languages available
|
// set all languages available
|
||||||
this.translate.addLangs(Object.keys(Language));
|
this.translate.addLangs(Object.keys(LanguageEnum));
|
||||||
|
|
||||||
// set language
|
// set language
|
||||||
this.setLanguageOnInit();
|
this.setLanguageOnInit();
|
||||||
@ -54,7 +52,7 @@ export class LanguageService {
|
|||||||
|
|
||||||
// set default language
|
// set default language
|
||||||
if (!this.translate.currentLang) {
|
if (!this.translate.currentLang) {
|
||||||
this.setLanguage(Language.FR);
|
this.setLanguage(LanguageEnum.FR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,8 +62,9 @@ export class LanguageService {
|
|||||||
this.setLanguage(this.storageService.language);
|
this.setLanguage(this.storageService.language);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private setLanguageFromBrowser(): void {
|
private setLanguageFromBrowser(): void {
|
||||||
const currentBrowserLanguage: Language = this.translate.getBrowserLang().toUpperCase() as Language;
|
const currentBrowserLanguage: LanguageEnum = this.translate.getBrowserLang().toUpperCase() as LanguageEnum;
|
||||||
console.log('currentBrowserLanguage', currentBrowserLanguage);
|
console.log('currentBrowserLanguage', currentBrowserLanguage);
|
||||||
if (this.translate.getLangs().includes(currentBrowserLanguage)) {
|
if (this.translate.getLangs().includes(currentBrowserLanguage)) {
|
||||||
this.setLanguage(currentBrowserLanguage);
|
this.setLanguage(currentBrowserLanguage);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { LocalStorage } from 'ngx-webstorage';
|
import { LocalStorage } from 'ngx-webstorage';
|
||||||
|
|
||||||
import { Language } from '../enums/language.enum';
|
import { LanguageEnum } from '../enums/language.enum';
|
||||||
import { Theme } from '../enums/theme.enum';
|
import { Theme } from '../enums/theme.enum';
|
||||||
import { Stack } from '../models/stack.model';
|
import { Stack } from '../models/stack.model';
|
||||||
import { Choice } from '../models/choice.model';
|
import { Choice } from '../models/choice.model';
|
||||||
@ -28,7 +28,7 @@ export class StorageService {
|
|||||||
public theme: Theme;
|
public theme: Theme;
|
||||||
|
|
||||||
@LocalStorage()
|
@LocalStorage()
|
||||||
public language: Language;
|
public language: LanguageEnum;
|
||||||
|
|
||||||
@LocalStorage()
|
@LocalStorage()
|
||||||
public userPolls: Poll[] = [];
|
public userPolls: Poll[] = [];
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</label>
|
</label>
|
||||||
({{ availableLanguages.length }} availableLanguages)
|
|
||||||
<select class="is-hidden" id="lang_selector" (change)="setLang()" [(ngModel)]="currentLang">
|
<select class="is-hidden" id="lang_selector" (change)="setLang()" [(ngModel)]="currentLang">
|
||||||
<option *ngFor="let language of availableLanguages" value="{{ language }}">
|
<option *ngFor="let language of availableLanguages" value="{{ language }}">
|
||||||
<!-- {{ language }} - -->
|
<!-- {{ language }} - -->
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
import { Language } from '../../../../core/enums/language.enum';
|
import { LanguageEnum } from '../../../../core/enums/language.enum';
|
||||||
import { LanguageService } from '../../../../core/services/language.service';
|
import { LanguageService } from '../../../../core/services/language.service';
|
||||||
import { StorageService } from '../../../../core/services/storage.service';
|
import { StorageService } from '../../../../core/services/storage.service';
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ import { StorageService } from '../../../../core/services/storage.service';
|
|||||||
styleUrls: ['./language-selector.component.scss'],
|
styleUrls: ['./language-selector.component.scss'],
|
||||||
})
|
})
|
||||||
export class LanguageSelectorComponent implements OnInit {
|
export class LanguageSelectorComponent implements OnInit {
|
||||||
public currentLang: Language;
|
public currentLang: LanguageEnum;
|
||||||
public availableLanguages: any = ['FR', 'EN', 'ES'];
|
public availableLanguages: any = ['FR', 'EN', 'ES'];
|
||||||
language: string;
|
language: string;
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ export const environment = {
|
|||||||
expiresDaysDelay: 30,
|
expiresDaysDelay: 30,
|
||||||
frontDomain: productionBaseUrl,
|
frontDomain: productionBaseUrl,
|
||||||
interval_days_default: 7,
|
interval_days_default: 7,
|
||||||
|
description_max_chars: 900,
|
||||||
maxCountOfAnswers: 300,
|
maxCountOfAnswers: 300,
|
||||||
production: true,
|
production: true,
|
||||||
showDemoWarning: false,
|
showDemoWarning: false,
|
||||||
|
Loading…
Reference in New Issue
Block a user