// Replace texts to translate kwizcom.placeholderTexts = { // Text to find: Text to replace "Pièces jointes": "Ajouter une pièce jointe", "Enter value here": "Entrez la valeur ici", "Select option": "Sélectionnez une option", "Enter a date": "Entrez une date", "Enter a name or email address": "Entrez un nom ou une adresse e-mail", "Alternative text": "Texte alternatif", "Enter a URL": "Entrez une URL" } kwizcom.buttonsTexts = { // Text to find: Text to replace "Save": "Sauvegarder", "SaveAs": "Appliquer", "Cancel": "Annuler", "Link": "Lien", } kwizcom.formTexts = { // Text to find: Text to replace "Attachments": "Pièces jointes", "Add attachment": "Ajouter une pièce jointe", "New Item": "Nouvel Élément", "You made edits": "Vous avez apporté des modifications", "You created this item": "Vous avez créé cet élément", "made edits": "apporté des modifications", "created this item": "a créé cet article", } kwizcom.ModernUILibrary.FormPage.OnReady("translateText", function (form) { debugger; replacePlaceholders(); replaceButtonsText(form) replaceFormTexts(); }); //#endregion Add empty on ready event handler replacePlaceholders = function (){ for(var oldPlaceJolder in kwizcom.placeholderTexts) { var newPlaceholder = kwizcom.placeholderTexts[oldPlaceJolder]; document.querySelectorAll('*[placeholder="' + oldPlaceJolder + '"]').forEach(function(el) { el.placeholder = newPlaceholder; }); document.querySelectorAll('span[class^="readOnlyPlaceholder"]').forEach(function(el) { if(el.innerHTML === oldPlaceJolder){ el.innerHTML = newPlaceholder; } }); } } replaceButtonsText = function(form){ for(var button in kwizcom.buttonsTexts) { var but = document.querySelector("[data-icon-name='" + button + "']") if(but){ but.parentNode.querySelector("span[class*='ms-Button-label']").innerHTML = kwizcom.buttonsTexts[button]; } } form.SetButtonState({ save: { text: kwizcom.buttonsTexts["Save"]}, apply: { text: kwizcom.buttonsTexts["SaveAs"]}, close: { text: kwizcom.buttonsTexts["Cancel"] } }); } replaceFormTexts = function(labelText, addAttachmentText){ var attachmentLabel = document.querySelector('label[for^="AttachmentsFieldControl"]'); if(attachmentLabel){ attachmentLabel.innerHTML = kwizcom.formTexts["Attachments"]; } var attachemntButton = document.querySelector("span:has([data-icon-name='Upload'])"); if(attachemntButton){ var addAttachmentLabel = attachemntButton.querySelector(".ms-Button-label"); if(addAttachmentLabel){ addAttachmentLabel.innerHTML = kwizcom.formTexts["Add attachment"]; } } var newItemLabel = document.querySelector("label[class*='kw-formTitle']"); if(newItemLabel){ newItemLabel.innerHTML = newItemLabel.innerHTML.replace("New Item", kwizcom.formTexts["New Item"]); } for(var personaText in kwizcom.formTexts) { document.querySelectorAll("div.ms-Persona-details").forEach(function(el) { el.innerHTML = el.innerHTML.replace(personaText, kwizcom.formTexts[personaText]); }); } }