Web component / Shared wording

<form-repeatable>

Share French action wording across two forms, with one instance override. See the README for configuration and precedence.

Set wording once for the document

One inline JSON script supplies the buttons’ wording. The guest form overrides only its Add label. The shared remove-aria-label puts each field’s context before the visible Remove wording. Add a second field to hear the contextual name on a Remove button.

Choose shorter wording and apply it: the demo edits that script and calls refreshLabels() on both instances without replacing their fields. The invalid choice deliberately supplies a number instead of a string; the previous wording stays in place. Choose either valid option to recover. Without JavaScript, the initial fields remain editable.

<script type="application/json" data-form-repeatable-config>
{
  "add-label": "Ajouter une entrée",
  "remove-label": "Retirer",
  "remove-aria-label": "{group} : {label}"
}
</script>

<form-repeatable id="shared-contacts" max="3">
  <div>
    <label for="contact-1">Contact 1</label>
    <input id="contact-1" name="contacts[]">
  </div>
</form-repeatable>

<form-repeatable id="shared-guests" max="3"
  add-label="Ajouter une invitée">
  <div>
    <label for="invitee-1">Invitée 1</label>
    <input id="invitee-1" name="invitees[]">
  </div>
</form-repeatable>

<script type="module">
  import '../define.js';
  // Après avoir modifié le script JSON :
  document.querySelectorAll('form-repeatable').forEach((element) => {
    element.refreshLabels();
  });
</script>
Contacts
Invitées

Les champs restent modifiables sans JavaScript.