Skip to main content

I have a multilingual skuid form that has been made using translated custom labels and translation workbench. The form adopts the language correctly when switching the running user language. However I want to send out this form to external users using force.com sites. This means that the Sites Guest User will be the running user and the locale settings of that user will control language. Is it possible for me to somehow override this so that my force.com sites Skuid page can be translated. I  can think of four different approaches to get the language code and either one of them would be ok for me

1: Using an URL-parameter
2: Using a hidden field on the record edited (so language would be pre-filled before sending out a link to the form
3: Using a picklist so that the user can change language themselves
4: Using the Browser language setting 

Can this be done using any of the above approaches?

I think I worked this out with a customer a while back, so I’m going off memory here, but here’s what I remember:


For Sites, another option you can use to set the page’s language is the apex:page/ tag’s language attribute, which overrides the language of the Site Guest User, if it is set. Since you’re on Force.com Sites, you’re already using the skuid:page/ Visualforce Component to load Skuid from within a VF Page, so what I recommend doing is to conditionally set the value of this language attribute based on a URL Parameter, e.g. “lang”, like this:


<apex:page language=“{!BLANKVALUE($CurrentPage.parameters.lang,‘en-US’)}”>

{!$ObjectType.Lead.label} - {!$ObjectType.Lead.labelPlural}

</apex:page>


where we’re using “en-US” as a default.


Then what you could do is have a somewhere on your page that lets the user change the language, and have an on-change event bound to it to reload the page, passing in the selected option’s value as the new lang parameter value.


Thanks Zach. I’ve tried using the page tags language attribute and it works fine with stuff translated with workbench. So for example a field name or picklist values are correctly translated and I can override the guest user with the URL parameter. However this does not seem to affect custom labels used as a resource in the skuid page. Actually some further testing shows that even changing the guest users language does not change the label. I’m using the {{$Label.LABELNAME}} merge syntax in the page. This is strange because when running the page within Salesforce and not wrapping it in a apex:page it will work fine translating everything correctly.


What happens if you just use {!$Label.LABELNAME} as a Visualforce variable in the VF Page? Does that get translated correctly? Or is it specific to Labels requested and displayed using Skuid?


I seem to remember there being some weirdness with Custom Labels, and I think we decided it was a Salesforce bug, but I’m not 100% sure on this. If it only happens for the Skuid Labels, let me know, I may have an idea of why that might be happening.


if I use the label directly in the VF page it gets displayed correctly. So the problem is specific to labels displayed using Skuid


and it does not seem to be specfically sites related. If I access the VF page a a running salesforce user with language English I can still override everything except custom label by the page language attribute


And putting {{$Param.lang}} within a template field on the skuid page will return a blank value. 


There also seem to be some caching issues involved. When displaying the VF page as a logged in user the {!$Label.LABELNAME}  in the VF page changes instantly on reload of the page and also the translated field label changes instantly. The Custom template always follows the language of the user and that also changes instantly when changing the user language.

However when displaying the VF page through sites (page attribute cache=“false”) The part in the VF page changes on reload and the same goes for the translated field label. But the Custom Label does change if the Site Guest users language is changed but there is a delay of at leat 10 minutes before this change happens. It’s like the custom label always follows the user setting but with a cache delay when accessing it through sites.


I’ve done several other test that confirms the following.

Custom labels within a Skuid page will always be translated to the running Users Language. When displayed through a force.com site there will be a delay between changing the guest users language and this being reflected in the page.

All other translations will follow the language page attribute if one is present otherwise the user language will be used. This includes custom labels displayed in a VF page and translated field labels, picklist values etc.


Also if putting the reference to the Custom Label within a formula field returning text and display that formula field in an VF page outside of Skuid. The formula field will always be the running user language. So i have a custom object Evaluation__c with a Custom formula field CustTemplate__c containing the text returning formula “$Label.Accurate_delivery” and that references a custom label translated to Swedish and English. If i then create a VF page like below:


<apex:page readonly="true" standardController="Evaluation__c" 


sidebar="false" showHeader="false" standardStylesheets="false" docType="html-5.0" showchat="false" cache="false" language="{!BLANKVALUE($CurrentPage.parameters.lang,'en-US')}"> {!$Label.Accurate_delivery} 
{!Evaluation__c.CustTemplate__c} </apex:page>

If accessing this file with the running user having english as user language and using the ?lang=sv-SE parameter the first reference to the label using the $Label variable directly will return a swedish result but the second reference to the Custom formula field will return english. This seems like a salesforce bug and possibly if Skuid uses formula processing to get to the label this might explain why translation of custom labels does not work within a Skuid page.


Peter,


The formula field thing you mentioned looks like a Salesforce bug, but the main part of this question represents a Skuid bug/enhancement — we have made some changes to allow you to pass in a “language” URL Parameter to any page, which will manually override the language used for rendering that page, and also a “language” property on the skuid:page/ component, letting you set it that way as well.


These changes will be available in the Superbank release.


Regards,


Zach


There are two approaches to get Labels within Skuid Pages to be translated in a Force.com Site environment (all of this was available as of the Superbank release, released in early 2015):


(a) Pass in the “language” URL Parameter into your pages, e.g.


/apex/skuid__UI?page=MySiteHomePage&language=en-US
/SiteHome?language=en-US


(b) Populate the language attribute on all skuid:page component(s) in the Visualforce Page(s) you’re using in the Force.com Site page


<apex:page title=“My Site Home Page” readonly=“true” doctype=“html-5.0” language=“en-US”>

<skuid:page page=“MySiteHomePage” language=“en-US”/>

</apex:page>


Reply