function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jon KeenerJon Keener 

Best Practices Ideas for Supporting Multi-Language in Visualforce

I need to implement multi language on approx. 17 Visualforce pages, to add support for the Chinese language.
I’m struggling to come up with an elegant way to implement this.  It would be nice to have a repository in Salesforce that would tie to text blobs that could be referenced, and the language conversions could be tied into standard Salesforce translation functionality.  I could build my own repository for this, (Which is what I would do if I was building a normal web page) but I’m concerned about the cost in SOQL calls and running into SOQL limits for text translation.  It would also be challenging to have the “hard coded text” for multi languages stored in the controller or another class.  Chances are I'll need to eventually add French, Spanish, etc.
I'm going to throw this out on ideas, but I was curious if anyone has figured out an elegant way to do this.  (
Jon Keener

I am happy to say that we just marked your idea as Under Construction :-) We're already working on basically the very thing you just described. You'll get high performance labels with translation workbench support and a way to access these labels from both Visualforce (e.g. {!$Label.labelA}) markup and Apex Code, replacement variables, etc.

in the interim I would suggest creating a controller extension apex class facadelike this:

public class Labels {
    public String getLabelA() { return getLabel('labelA'); }
    public String getLabelB() { return getLabel('labelB'); }
    public String getLabelC() { return getLabel('labelC'); }
    private String getLabel(String label) {
        return labels.get(UserInfo.getLanguage()).get(label);
    private static final Map<String, Map<String, String>> labels = new Map<String, Map<String, String>>();
    static {
        Map<String, String> m = new Map<String, String>();
        labels.put('en', m);
        m.put('labelA', 'english label A');
        m.put('labelB', 'english label B');
        m.put('labelC', 'english label C');
        m = new Map<String, String>();
        labels.put('zh', new Map<String, String>());
        m.put('labelA', 'chinese label A');
        m.put('labelB', 'chinese label B');
        m.put('labelC', 'chinese label C');

You could obviously make this more sophisticated and also clean up the redundancy in the initialization but I think this illustrates what I am talking about...

Message Edited by dchasman on 06-26-2008 08:02 PM

Hi Doug Chasman


I am also looking to create an application using and apex to support mulitple language atleast for static content.


In the application dynamically need to show the static text based on selected language.


For example when the user click the english version all the static content(messages, text on buttons etc.) need to be displayed in english. Otherwise based on the selected language.



I tried the language attribute as follows but did not work.


<apex:page language="fr"


Could you let me know the best way or any samples to implement this.






Praveen KimarPraveen Kimar



I also have the same problem. I tried enabling with translation workbench as well. but it didn't work for me.


I just want to translate the complete VF page into a user selected language. I tried setting the language attribute for <apex:page> page tag. but it didn't work. I was just wondering why this is not working.


Could any one suggest how can we implement the translation for VF pages.


Thank you,

Praveen K.