<apex:outputText> accepts an arbitrary number of nested param tags, which is useful for inserting values in Custom Label translations.

Unfortunately there's a bug: if there's an apostrophe character in a translation it will prevent the substitution of values after the apostrophe. This can be circumvented by doubling the apostrophe (How to programmatically double apostrophes in custom label translations?), but using this wouldn't be DRY.

Is it possible to "extend" the outputText component so that inside a custom component the apostrophe doubling could be done automatically?

I'm looking for implementing something like this:

<c:translate label="{!$Label.myLabel}">
  <apex:param value="{!firstParam}"/>
  <apex:param value="{!secondParam}"/>

I haven't been able to figure out yet how to access these parameters from the custom component's controller class.

Essentially this is what I'd like to shorten:

<apex:outputText value="{!SUBSTITUTE($Label.myLabel, $Label.SingleQuote, $Label.SingleQuote & $Label.SingleQuote)}">
  <apex:param value="{!firstParam}"/>
  <apex:param value="{!secondParam}"/>

Update: I'd like to emphasize that I want to accept any number of parameters for this component, as there can be no limit as to how many placeholders will the string contain which I need to translate.

  • Mostly just glad I found the double-quote workaround. Thanks for this!
    – psheil
    Commented Sep 14, 2016 at 23:30

1 Answer 1


I think what you want is for your component to just be:

    <apex:attribute type="String" name="label" description="Label to output" />
    <apex:variable var="singlequote" value="{!$Label.SingleQuote}" />
    <apex:outputText value="{!SUBSTITUTE(text, singlequote, singlequote & singlequote)}">

Then in your page, you just do:

<c:translate label="{!$Label.myLabel}" / >

No inner params necessary.

  • How would I pass an arbitrary number of values to the Custom Label if not via params? Commented May 13, 2016 at 7:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .