Translate custom form buttons

This commit is contained in:
nemunaire 2023-01-18 18:35:25 +01:00
parent a050459f1a
commit 63e6389ce3
5 changed files with 22 additions and 13 deletions

View File

@ -130,11 +130,11 @@ func GenStructFields(data interface{}) (fields []*Field) {
func GenDefaultSettingsForm(data interface{}) *CustomForm { func GenDefaultSettingsForm(data interface{}) *CustomForm {
return &CustomForm{ return &CustomForm{
Fields: GenStructFields(data), Fields: GenStructFields(data),
NextButtonText: "Create", NextButtonText: "common.create-thing",
NextEditButtonText: "Update", NextEditButtonText: "common.update",
NextButtonState: 1, NextButtonState: 1,
PreviousButtonText: "Use another source", PreviousButtonText: "provider.another",
PreviousEditButtonText: "Cancel", PreviousEditButtonText: "common.cancel",
PreviousButtonState: -1, PreviousButtonState: -1,
} }
} }

View File

@ -67,7 +67,7 @@ func settingsForm(edit bool) *forms.CustomForm {
form := forms.GenDefaultSettingsForm(nil) form := forms.GenDefaultSettingsForm(nil)
form.Fields = srcFields form.Fields = srcFields
form.NextButtonText = "Next >" form.NextButtonText = "common.next"
return form return form
} }
@ -91,7 +91,7 @@ func settingsAskCredentials(cfg *config.Options, recallid string, session *happy
return &forms.CustomForm{ 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", 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", NextButtonText: "Go to OVH",
PreviousButtonText: "< Previous", PreviousButtonText: "common.previous",
NextButtonLink: response.ValidationURL, NextButtonLink: response.ValidationURL,
PreviousButtonState: 0, PreviousButtonState: 0,
}, map[string]interface{}{ }, map[string]interface{}{

View File

@ -7,6 +7,7 @@
} from 'sveltestrap'; } from 'sveltestrap';
import type { CustomForm } from '$lib/model/custom_form'; import type { CustomForm } from '$lib/model/custom_form';
import { t } from '$lib/translations';
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
@ -34,7 +35,7 @@
{#if previousInProgress} {#if previousInProgress}
<Spinner label="Spinning" size="sm" /> <Spinner label="Spinning" size="sm" />
{/if} {/if}
{form.previousButtonText} {$t(form.previousButtonText)}
</Button> </Button>
{/if} {/if}
{#if (!form.nextEditButtonText || !edit) && form.nextButtonText} {#if (!form.nextEditButtonText || !edit) && form.nextButtonText}
@ -48,7 +49,7 @@
{#if nextInProgress} {#if nextInProgress}
<Spinner label="Spinning" size="sm" /> <Spinner label="Spinning" size="sm" />
{/if} {/if}
{form.nextButtonText} {$t(form.nextButtonText)}
</Button> </Button>
{/if} {/if}
{#if edit && form.previousEditButtonText} {#if edit && form.previousEditButtonText}
@ -63,7 +64,7 @@
{#if previousInProgress} {#if previousInProgress}
<Spinner label="Spinning" size="sm" /> <Spinner label="Spinning" size="sm" />
{/if} {/if}
{form.previousEditButtonText} {$t(form.previousEditButtonText)}
</Button> </Button>
{/if} {/if}
{#if edit && form.nextEditButtonText} {#if edit && form.nextEditButtonText}
@ -77,7 +78,7 @@
{#if nextInProgress} {#if nextInProgress}
<Spinner label="Spinning" size="sm" /> <Spinner label="Spinning" size="sm" />
{/if} {/if}
{form.nextEditButtonText} {$t(form.nextEditButtonText)}
</Button> </Button>
{/if} {/if}
{:else} {:else}
@ -92,7 +93,7 @@
{#if previousInProgress} {#if previousInProgress}
<Spinner label="Spinning" size="sm" /> <Spinner label="Spinning" size="sm" />
{/if} {/if}
Cancel {$t('common.cancel')}
</Button> </Button>
<Button <Button
type="submit" type="submit"
@ -104,7 +105,7 @@
{#if nextInProgress} {#if nextInProgress}
<Spinner label="Spinning" size="sm" /> <Spinner label="Spinning" size="sm" />
{/if} {/if}
Next &gt; {$t('common.next')} &gt;
</Button> </Button>
{/if} {/if}
</div> </div>

View File

@ -39,15 +39,18 @@
"field": "Field", "field": "Field",
"go": "Go!", "go": "Go!",
"name": "Name", "name": "Name",
"next": "Next",
"no-content": "No content", "no-content": "No content",
"no-thing": "No {{thing}}", "no-thing": "No {{thing}}",
"new-row": "New row", "new-row": "New row",
"password": "Password", "password": "Password",
"previous": "Previous",
"rename": "Rename", "rename": "Rename",
"resolver": "Resolver", "resolver": "Resolver",
"run": "Run the request!", "run": "Run the request!",
"survey": "A remark? a comment to share? Don't hesitate to write us!", "survey": "A remark? a comment to share? Don't hesitate to write us!",
"spinning": "Spinning", "spinning": "Spinning",
"update": "Update",
"welcome": { "welcome": {
"start": "Welcome to ", "start": "Welcome to ",
"end": "!" "end": "!"
@ -229,6 +232,7 @@
"form-new": "Add a new service to {{domain}}" "form-new": "Add a new service to {{domain}}"
}, },
"provider": { "provider": {
"another": "Use another provider",
"associations": "{{count:eq; 0:no domain associated; 1:{{count}} domain associated; default:{{count}} domains associated}}", "associations": "{{count:eq; 0:no domain associated; 1:{{count}} domain associated; default:{{count}} domains associated}}",
"check-config": "Check your provider configuration", "check-config": "Check your provider configuration",
"delete": "Delete this domain provider", "delete": "Delete this domain provider",

View File

@ -38,11 +38,14 @@
"field": "Champ", "field": "Champ",
"go": "C'est parti!", "go": "C'est parti!",
"name": "Nom", "name": "Nom",
"next": "Suivant",
"password": "Mot de passe", "password": "Mot de passe",
"previous": "Précédent",
"rename": "Renommer", "rename": "Renommer",
"resolver": "Résolveur", "resolver": "Résolveur",
"run": "Lancer l'opération!", "run": "Lancer l'opération!",
"spinning": "Chargement", "spinning": "Chargement",
"update": "Mettre à jour",
"help": "Besoin d'aide?", "help": "Besoin d'aide?",
"records": "{{n:eq; 0:aucun enregistrement {{type}}; 1:enregistrement {{type}}; default:enregistrements {{type}}}}", "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!", "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)" "showDNSSEC": "Afficher les enregistrements DNSSEC dans la réponse (s'il y en a)"
}, },
"provider": { "provider": {
"another": "Choisir un autre fournisseur",
"delete": "Supprimer cet hébergeur de domaines", "delete": "Supprimer cet hébergeur de domaines",
"find": "Vous ne trouvez pas votre hébergeur de domaines ici?", "find": "Vous ne trouvez pas votre hébergeur de domaines ici?",
"name-your": "Nommer cet hébergeur de domaines", "name-your": "Nommer cet hébergeur de domaines",
@ -316,4 +320,4 @@
"no-group": "Divers", "no-group": "Divers",
"title": "Vos groupes" "title": "Vos groupes"
} }
} }