Hello,
I have a Custom Marketing Form in German, what is the best way to translate the fields on the form to English?
The form is embedded on a website and creates leads in Dynamics Sales.
Form:
Hello,
I have a Custom Marketing Form in German, what is the best way to translate the fields on the form to English?
The form is embedded on a website and creates leads in Dynamics Sales.
Form:
Hi Niko_2109,
If you want to translate the marketing list according to the browser language you can do this by inserting the marketing page using Jscript.
This script can translate the label (the first one in Field properties) to other language according to your browser language. Put it behind the </body> in the marketing page HTML.
<script>
// Do translation after marketing form is loaded
MsCrmMkt.MsCrmFormLoader.on("afterFormLoad", function (event) {
// Detect current user language
var langName = detectLanguage();
// Only do translation if current language is not German
if (langName !== "deu") {
// Field name are saved in label element
// See Field label: Outbound marketing -> Marketing templates -> Form fields
var labels = document.getElementsByTagName("label");
labels[0].innerText = translation[langName].firstname;
labels[1].innerText = translation[langName].lastname;
labels[2].innerText = translation[langName].gender;
labels[3].innerText = translation[langName].email;
labels[4].innerText = translation[langName].phonenumber;
labels[5].innerText = translation[langName].companyname;
labels[6].innerText = translation[langName].country;
labels[7].innerText = translation[langName].jobtitle;
}
});
function detectLanguage() {
var userLanguage = navigator.language.slice(0, 2);
/**
* You can extend more translation texts,
* For example, if contact speaks spanish, then userLanguage should be "es",
* you can add case "es": return "Spanish"; then add new spanish translation in translation variable.
* Currently it'll only translate fields for English and German contacts, if he/she is a Spanish or Italian,
* he/she will still see form default language (Such as your form is German, which means not translate, it is still expressed as German)
**/
switch (userLanguage) {
case "en":
return "english";
case "de":
return "German";
default:
return "deu";
}
}
var translation = {
english: {
firstname: "firstname",
lastname: "lastname",
gender:"gender",
email: "email",
phonenumber:"phonenumber",
companyname:"companyname",
country:"country",
jobtitle: "jobtitle"
},
German: {
firstname: "Vorname",
lastname: "Nachname",
gender:"Geschlecht",
email: "E-Mail",
phonenumber:"Telefonnummer",
companyname:"Name des Unternehmens",
country:"land",
jobtitle: "Position"
}
// Extend translation here, each translation should be separated with comma, but comma is not required for final item
};
</script>
For more information, please refer to the original article: