From 63e6389ce3974d98300644115aab40fc7ef1ded4 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Wed, 18 Jan 2023 18:35:25 +0100 Subject: [PATCH] Translate custom form buttons --- forms/field.go | 8 ++++---- providers/ovh_settings.go | 4 ++-- .../providers/SettingsStateButtons.svelte | 13 +++++++------ ui/src/lib/locales/en.json | 4 ++++ ui/src/lib/locales/fr.json | 6 +++++- 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/forms/field.go b/forms/field.go index 853f692..1469231 100644 --- a/forms/field.go +++ b/forms/field.go @@ -130,11 +130,11 @@ func GenStructFields(data interface{}) (fields []*Field) { func GenDefaultSettingsForm(data interface{}) *CustomForm { return &CustomForm{ Fields: GenStructFields(data), - NextButtonText: "Create", - NextEditButtonText: "Update", + NextButtonText: "common.create-thing", + NextEditButtonText: "common.update", NextButtonState: 1, - PreviousButtonText: "Use another source", - PreviousEditButtonText: "Cancel", + PreviousButtonText: "provider.another", + PreviousEditButtonText: "common.cancel", PreviousButtonState: -1, } } diff --git a/providers/ovh_settings.go b/providers/ovh_settings.go index 152aa47..487d6c5 100644 --- a/providers/ovh_settings.go +++ b/providers/ovh_settings.go @@ -67,7 +67,7 @@ func settingsForm(edit bool) *forms.CustomForm { form := forms.GenDefaultSettingsForm(nil) form.Fields = srcFields - form.NextButtonText = "Next >" + form.NextButtonText = "common.next" return form } @@ -91,7 +91,7 @@ func settingsAskCredentials(cfg *config.Options, recallid string, session *happy return &forms.CustomForm{ BeforeText: "In order allows happyDomain to get and update yours domains, you have to let us access them. To avoid storing your credentials, we will store a unique token that will be associated with your account. For this purpose, you will be redirected to an OVH login screen. The registration will automatically continue", NextButtonText: "Go to OVH", - PreviousButtonText: "< Previous", + PreviousButtonText: "common.previous", NextButtonLink: response.ValidationURL, PreviousButtonState: 0, }, map[string]interface{}{ diff --git a/ui/src/lib/components/providers/SettingsStateButtons.svelte b/ui/src/lib/components/providers/SettingsStateButtons.svelte index cb604b3..77264f1 100644 --- a/ui/src/lib/components/providers/SettingsStateButtons.svelte +++ b/ui/src/lib/components/providers/SettingsStateButtons.svelte @@ -7,6 +7,7 @@ } from 'sveltestrap'; import type { CustomForm } from '$lib/model/custom_form'; + import { t } from '$lib/translations'; const dispatch = createEventDispatcher(); @@ -34,7 +35,7 @@ {#if previousInProgress} {/if} - {form.previousButtonText} + {$t(form.previousButtonText)} {/if} {#if (!form.nextEditButtonText || !edit) && form.nextButtonText} @@ -48,7 +49,7 @@ {#if nextInProgress} {/if} - {form.nextButtonText} + {$t(form.nextButtonText)} {/if} {#if edit && form.previousEditButtonText} @@ -63,7 +64,7 @@ {#if previousInProgress} {/if} - {form.previousEditButtonText} + {$t(form.previousEditButtonText)} {/if} {#if edit && form.nextEditButtonText} @@ -77,7 +78,7 @@ {#if nextInProgress} {/if} - {form.nextEditButtonText} + {$t(form.nextEditButtonText)} {/if} {:else} @@ -92,7 +93,7 @@ {#if previousInProgress} {/if} - Cancel + {$t('common.cancel')} {/if} diff --git a/ui/src/lib/locales/en.json b/ui/src/lib/locales/en.json index 8218f43..6724aed 100644 --- a/ui/src/lib/locales/en.json +++ b/ui/src/lib/locales/en.json @@ -39,15 +39,18 @@ "field": "Field", "go": "Go!", "name": "Name", + "next": "Next", "no-content": "No content", "no-thing": "No {{thing}}", "new-row": "New row", "password": "Password", + "previous": "Previous", "rename": "Rename", "resolver": "Resolver", "run": "Run the request!", "survey": "A remark? a comment to share? Don't hesitate to write us!", "spinning": "Spinning", + "update": "Update", "welcome": { "start": "Welcome to ", "end": "!" @@ -229,6 +232,7 @@ "form-new": "Add a new service to {{domain}}" }, "provider": { + "another": "Use another provider", "associations": "{{count:eq; 0:no domain associated; 1:{{count}} domain associated; default:{{count}} domains associated}}", "check-config": "Check your provider configuration", "delete": "Delete this domain provider", diff --git a/ui/src/lib/locales/fr.json b/ui/src/lib/locales/fr.json index 13b2b1e..9eb968d 100644 --- a/ui/src/lib/locales/fr.json +++ b/ui/src/lib/locales/fr.json @@ -38,11 +38,14 @@ "field": "Champ", "go": "C'est parti !", "name": "Nom", + "next": "Suivant", "password": "Mot de passe", + "previous": "Précédent", "rename": "Renommer", "resolver": "Résolveur", "run": "Lancer l'opération !", "spinning": "Chargement", + "update": "Mettre à jour", "help": "Besoin d'aide ?", "records": "{{n:eq; 0:aucun enregistrement {{type}}; 1:enregistrement {{type}}; default:enregistrements {{type}}}}", "survey": "Une remarque ? un commentaire à partager ? N'hésitez pas à nous écrire !", @@ -291,6 +294,7 @@ "showDNSSEC": "Afficher les enregistrements DNSSEC dans la réponse (s'il y en a)" }, "provider": { + "another": "Choisir un autre fournisseur", "delete": "Supprimer cet hébergeur de domaines", "find": "Vous ne trouvez pas votre hébergeur de domaines ici ?", "name-your": "Nommer cet hébergeur de domaines", @@ -316,4 +320,4 @@ "no-group": "Divers", "title": "Vos groupes" } -} \ No newline at end of file +}