1

I have a force.com site which I would like to translate the fields name of a form when a button was clicked.

What I did so far:

  • I created a basic form
  • I activated the Spanish translation and translated the custom fields label
  • I used {!$ObjectType.Payment__c.fields.Email__c.label} to displau the label value of my field.
  • I used the apex:page param : language="{!$CurrentPage.parameters.lang}

    <apex:form styleClass="form-horizontal" id="formId" >
        <h5>
            // some picklist with supported langs is required
        </h5>
        <label id="EmailId" class="control-label right-side" for="Email">{!$ObjectType.Payment__c.fields.Email__c.label}</label>
        <apex:input  html-placeholder="Please Enter Email"  styleClass="form-control" value="{!email}" />
    </apex:form>
    

Because the Url is a site that opens for everyone - I don't want to use the lang based on the logged in user because I don't have one.

I tried to use a javascript function where : window.location.search = 'lang=es'; Which is actually worked from developer console in chrome- but from visual force page its do nothing.

What I do want - Is to have a picklist or a button which I could choose the lang that I want to see the form.

If I adding manually to the URL : siteUrl**?lang=se** then it works. But I want to know how can I change or add this param on the URL - from the controller or from Javascript.

  • try PageReference in apex: return new PageReference('/siteurl?lang=se'); – Mahmood Feb 20 at 12:10
  • for JavaScript one you check this question Replace the parameter in URL & refresh the page. – Mahmood Feb 20 at 12:12
  • Hey @Mahmood the second link helped a bit - but this solution does not support Internet Explorer browser and this is a little problem for my users... The first solution does not help me in this case. Thanks! – Salvation Feb 25 at 7:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.