Using CustomLabel
s, we are able to use the {!format($Label.myNamespace.myLabelName, v.myAttribute}
in lightning component markup where $Label.myNamespace.myLabelName
looks like:
<?xml version="1.0" encoding="UTF-8"?>
<CustomLabels xmlns="http://soap.sforce.com/2006/04/metadata">
<labels>
<fullName>myLabelName</fullName>
<language>en_US</language>
<protected>true</protected>
<shortDescription>my label</shortDescription>
<value>Label text with a parameter {0}</value>
</labels>
</CustomLabels>
This works well for simple string values.
However, in the case of a link that looks like
Click <a href="http://example.com">here</a>!
how would we pass the anchor tag into the format
function, or more generally, how do we handle internationalization (i18n) properly in lightning components with link text? other I18n frameworks outside of Salesforce have allowed passing in component markup as a parameter.
the two requirements would be
- changing the custom label for a different translation should not break the link (as long as the parameter
{0}
is maintained - translators looking at the custom labels should understand that the link parameter
{0}
can be moved around in the markup to satisfy different grammatical language needs
if anyone has solved this issue already, would greatly appreciate some pointers towards a solution