Provide form in the desired language

Hello everyone,

I created two forms in Plumsail in the respective languages and made them available with the following Form IDs.

if(_spPageContextInfo.currentUICultureName == 'de-DE'){
return '1539b33d-f017-4a09-8903-d33a918df10b';
}

if(_spPageContextInfo.currentUICultureName == 'en-US'){
return 'f588b3be-9f92-41a3-843a-70209681e96f';
}

Depending on the language configured in the Explorer, the corresponding form will be called.
Now, I would like to give the user the option to select the language themselves within the form through a dropdown menu.

// Drop-down field for the language
var languageField = fd.field('DropDown1');

// Function for setting the form and language based on the selection
function setFormLanguageBasedOnSelection() {
    var selectedLanguage = languageField.value;
    var formId = '';
   
    // Set form ID depending on selection
    if (selectedLanguage === 'Deutsch') {
        formId = '1539b33d-f017-4a09-8903-d33a918df10b';
    } else if (selectedLanguage === 'Englisch') {
        formId = 'f588b3be-9f92-41a3-843a-70209681e96f';
    }
   
    // If a valid form ID is available, forward and reload
    if (formId) {
        // Set URL with form ID
        var newUrl = `https://xyz.sharepoint.com/sites/SitePages/Form123.aspx?formId=${formId}`;
        if (window.location.href !== newUrl) {
            window.location.href = newUrl; // Reload page with new form ID
        }
    }
}

// Check initial language setting and set drop-down value
function setDropdownBasedOnUrl() {
    var urlParams = new URLSearchParams(window.location.search);
    var formId = urlParams.get('formId');
   
    // Sets the language of the dropdown based on the `formId` parameter in the URL
    if (formId === '1539b33d-f017-4a09-8903-d33a918df10b') {
        languageField.value = 'Deutsch';
    } else if (formId === 'f588b3be-9f92-41a3-843a-70209681e96f') {
        languageField.value = 'Englisch';
    }
}

// Call up Initial to apply the language setting
setDropdownBasedOnUrl();

// Reload language if the selection in the dropdown changes
languageField.$on('change', setFormLanguageBasedOnSelection);

The selected Form ID is reloaded in the URL, but the selected language does not change.

What other approach could I take?

Thx
Andreas

Hi @Andreas_Sch,

Could you try the approach from this post?

Great, it’s working exactly as desired now.
Thank you very much!