Activity Forums Salesforce® Discussions What is best practice to refer dynamic custom messages in Salesforce Visualforce with multi-language support?

  • shariq

    Member
    September 22, 2018 at 6:01 pm

    Using Custom Label or OutputField or InputField tag, Platform itself will take care of internationalization. However in some cases, Message needs to be dynamic at the same time it should also support muti-language. In Custom Label, we cannot save dynamic String.

    Let’s assume we want to show message something like “DEVELOPERNAME is not authorized to access this page”.
    Here, Developername should be dynamically changed in visualforce which supports multilanguage. For each developername, it is not feasible to create custom labels. So below workaround can be used :

    Step 1 : Create a Custom Label with text “{0} is not authorized to access this page“. In every language, dynamic value should represented by {0}.

    Step 2 : In Controller of Visualforce write something like this :

    1
    String developerName = 'Some DeveloperName';
    2
    String message = String.format(Label.DEVELOPERNA, new String[] { developerName });

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos