I have a custom label which contains a couple of parameters:
Hello, {0} the other param is {1}.
I wish to output this value in a Visualforce Page like so:
<apex:variable var="firstParam" value="THE_NAME"/>
<apex:variable var="secondParam" value="SECOND_PARAM"/>
<apex:outputText value="{!$Label.Whatever}">
<apex:param value="{!firstParam}"/>
<apex:param value="{!secondParam}"/>
</apex:outputText>
This of course outputs this:
Hello, THE_NAME, the other param is SECOND_PARAM.
So far so good. Now, if a translation for this custom label contains an apostrophe -- Hello, {0}, it's the second param: {1}.
--, the string interpolation breaks like this:
Hello, THE_NAME, it's the second param: {1}.
I've discovered that I need to double the apostrophe -- Hello, {0}, it''s the second param: {1}.
-- to make it work:
Hello, THE_NAME, it's the second param: SECOND_PARAM.
Escaping certain characters in strings is definitely a job for the computer rather than a translator.
What's the Visualforce way to have the single apostrophes in a custom label escaped?
I've tried to call a String replace method on the $Label.Whatever part, but this doesn't even compile. I also couldn't do String($Label.Whatever)
to cast it, and I haven't been able to find any solution on the net.