+ Start a Discussion
magandrezmagandrez 

(Visualforce page + Custom Labels) - Header and Sidebar

Hi,

 

I'm developing a visualforce page where I need to support translations. My approach is to create Custom Labels and use the "language" attribute in apex page to provide the language string.

 

 

<apex:page controller="MyController"  language="{!language}">

...


<apex:pageBlock title="{!$Label.My_Label}" mode="detail"> 

...

 

The language string gets its value in the controller (actually is a value parsed from an XML).

 

My question is:

 

How can I generate the Visualforce page so that the header and sidebar will have the standard language value (the one selected by the user) but the rest of the labels in the VF will be translated according to the parameter passed from the controller?

 

I will appreciate any kind of aproach that is sustainable (not hardcoding the labels in the controller). Many thanks.

 

MGA

gmcateer at gmailgmcateer at gmail

What if you created an object that held the labels based on language and you retrieved that as part of the VF page?

magandrezmagandrez
Hi,

How would you procceed? I wouldn't like to hardcode the labels in a map or
another object in the controller because there will be many languages and
It wouldn't be easy to maintain that way.

Thanks.

MGA
gmcateer at gmailgmcateer at gmail

Unless you are going to use some type of Translator service and pass it the language and text to translate, then dynamically set the labels...which seems to be full of problems.

 

I would setup an object with language, some type of index, and the specific text in that language. Then you'd have to SOQL it and populate for the page when it displays. Maybe it defaults to English if no language or non-existing language is specified.

 

It's easy enough to maintain, just setup a page to do it.

 

You are going to have to maintain this somewhere, either in code or in an object....unless you are able to dynamically call a service.