From 586d8c440d2b31911c2e632d309cda0769d556f3 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 7 Oct 2020 15:37:23 +0200 Subject: [PATCH] Add languages to admin settings Signed-off-by: Thomas Citharel --- config/config.exs | 1 + js/src/graphql/admin.ts | 12 +++++ js/src/i18n/en_US.json | 6 ++- js/src/i18n/fr_FR.json | 8 +++- js/src/types/admin.model.ts | 6 +++ js/src/views/Admin/Settings.vue | 81 ++++++++++++++++++++++++++++++--- lib/graphql/resolvers/admin.ex | 20 ++++++-- lib/graphql/resolvers/config.ex | 1 + lib/graphql/schema/admin.ex | 11 +++++ lib/graphql/schema/config.ex | 1 + lib/mobilizon/admin/admin.ex | 38 ++++++++++++++-- lib/mobilizon/cldr.ex | 2 +- lib/mobilizon/config.ex | 12 ++++- mix.exs | 1 + mix.lock | 1 + 15 files changed, 179 insertions(+), 22 deletions(-) diff --git a/config/config.exs b/config/config.exs index 37f6a25d4..d833be2f1 100644 --- a/config/config.exs +++ b/config/config.exs @@ -18,6 +18,7 @@ config :mobilizon, :instance, hostname: "localhost", registrations_open: false, registration_email_allowlist: [], + languages: [], demo: false, repository: Mix.Project.config()[:source_url], allow_relay: true, diff --git a/js/src/graphql/admin.ts b/js/src/graphql/admin.ts index 742a29391..b135a0016 100644 --- a/js/src/graphql/admin.ts +++ b/js/src/graphql/admin.ts @@ -104,6 +104,15 @@ export const REJECT_RELAY = gql` ${RELAY_FRAGMENT} `; +export const LANGUAGES = gql` + query { + languages { + code + name + } + } +`; + export const ADMIN_SETTINGS_FRAGMENT = gql` fragment adminSettingsFragment on AdminSettings { instanceName @@ -118,6 +127,7 @@ export const ADMIN_SETTINGS_FRAGMENT = gql` instancePrivacyPolicyUrl instanceRules registrationsOpen + instanceLanguages } `; @@ -144,6 +154,7 @@ export const SAVE_ADMIN_SETTINGS = gql` $instancePrivacyPolicyUrl: String $instanceRules: String $registrationsOpen: Boolean + $instanceLanguages: [String] ) { saveAdminSettings( instanceName: $instanceName @@ -158,6 +169,7 @@ export const SAVE_ADMIN_SETTINGS = gql` instancePrivacyPolicyUrl: $instancePrivacyPolicyUrl instanceRules: $instanceRules registrationsOpen: $registrationsOpen + instanceLanguages: $instanceLanguages ) { ...adminSettingsFragment } diff --git a/js/src/i18n/en_US.json b/js/src/i18n/en_US.json index 683513bf5..845543775 100644 --- a/js/src/i18n/en_US.json +++ b/js/src/i18n/en_US.json @@ -789,5 +789,9 @@ "Congratulations, your account is now created!": "Congratulations, your account is now created!", "Now, create your first profile:": "Now, create your first profile:", "If you have opted for manual validation of participants, Mobilizon will send you an email to inform you of new participations to be processed. You can choose the frequency of these notifications below.": "If you have opted for manual validation of participants, Mobilizon will send you an email to inform you of new participations to be processed. You can choose the frequency of these notifications below.", - "You will be able to add an avatar and set other options in your account settings.": "You will be able to add an avatar and set other options in your account settings." + "You will be able to add an avatar and set other options in your account settings.": "You will be able to add an avatar and set other options in your account settings.", + "Instance languages": "Instance languages", + "Main languages you/your moderators speak": "Main languages you/your moderators speak", + "Select languages": "Select languages", + "No languages found": "No languages found" } diff --git a/js/src/i18n/fr_FR.json b/js/src/i18n/fr_FR.json index 882e5db37..2b79d4db8 100644 --- a/js/src/i18n/fr_FR.json +++ b/js/src/i18n/fr_FR.json @@ -388,7 +388,7 @@ "My events": "Mes évènements", "My groups": "Mes groupes", "My identities": "Mes identités", - "NOTE! The default terms have not been checked over by a lawyer and thus are unlikely to provide full legal protection for all situations for an instance admin using them. They are also not specific to all countries and jurisdictions. If you are unsure, please check with a lawyer.": "REMARQUE : les conditions par défaut n'ont pas été vérifiées par un juriste et ne sont donc susceptibles de ne pas offrir une protection juridique complète dans toutes les situations pour un·e administrateur·ice d'instance qui les utilise. Elles ne sont pas non plus spécifiques à tous les pays et juridictions. Si vous n'êtes pas sûr, veuillez consulter un juriste.", + "NOTE! The default terms have not been checked over by a lawyer and thus are unlikely to provide full legal protection for all situations for an instance admin using them. They are also not specific to all countries and jurisdictions. If you are unsure, please check with a lawyer.": "REMARQUE : les conditions par défaut n'ont pas été vérifiées par un·e juriste et ne sont donc susceptibles de ne pas offrir une protection juridique complète dans toutes les situations pour un·e administrateur·ice d'instance qui les utilise. Elles ne sont pas non plus spécifiques à tous les pays et juridictions. Si vous n'êtes pas sûr, veuillez consulter un·e juriste.", "Name": "Nom", "New discussion": "Nouvelle discussion", "New email": "Nouvelle adresse e-mail", @@ -831,5 +831,9 @@ "Congratulations, your account is now created!": "Bravo, votre compte est dorénavant créé !", "Now, create your first profile:": "Maintenant, créez votre premier profil :", "If you have opted for manual validation of participants, Mobilizon will send you an email to inform you of new participations to be processed. You can choose the frequency of these notifications below.": "Si vous avez opté pour la validation manuelle des participantes, Mobilizon vous enverra un email pour vous informer des nouvelles participations à traiter. Vous pouvez choisir la fréquence de ces notifications ci-dessous.", - "You will be able to add an avatar and set other options in your account settings.": "Vous pourrez ajouter un avatar et définir d'autres options dans les paramètres de votre compte." + "You will be able to add an avatar and set other options in your account settings.": "Vous pourrez ajouter un avatar et définir d'autres options dans les paramètres de votre compte.", + "Instance languages": "Langues de l'instance", + "Main languages you/your moderators speak": "Principales langues parlées par vous / vos modérateurs", + "Select languages": "Choisissez une langue", + "No languages found": "Aucune langue trouvée" } diff --git a/js/src/types/admin.model.ts b/js/src/types/admin.model.ts index 6791ec120..cf50a4f32 100644 --- a/js/src/types/admin.model.ts +++ b/js/src/types/admin.model.ts @@ -20,6 +20,11 @@ export enum InstancePrivacyType { CUSTOM = "CUSTOM", } +export interface ILanguage { + code: string; + name: string; +} + export interface IAdminSettings { instanceName: string; instanceDescription: string; @@ -33,4 +38,5 @@ export interface IAdminSettings { instancePrivacyPolicyUrl: string | null; instanceRules: string; registrationsOpen: boolean; + instanceLanguages: string[]; } diff --git a/js/src/views/Admin/Settings.vue b/js/src/views/Admin/Settings.vue index 923782bb7..214faa8ca 100644 --- a/js/src/views/Admin/Settings.vue +++ b/js/src/views/Admin/Settings.vue @@ -43,6 +43,24 @@

{{ $t("Registration is closed.") }}

+
+ + + {{ $t("Main languages you/your moderators speak") }} + + + + +
@@ -256,32 +274,55 @@