Just trying to format a dictionary label using \n
characters and when it is returned via API. The new line characters have been escaped with an extra backslash.
Is there any way I can turn this off for these labels?
1 Answer
The translation is performed in Sitecore with the <getTranslation>
pipeline.
Maybe you can add a processor like this:
public class RemoveEscapes
{
public void Process(GetTranslationArgs args)
{
Assert.ArgumentNotNull(args, "args");
if (args.HasResult)
{
args.Result = args.Result.Replace("\\n", "\n");
}
}
}
And add a patch config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<getTranslation>
<processor type="Example.Foundation.Pipelines.RemoveEscapes, Example.Foundation"
patch:after="processor[@type='Sitecore.Pipelines.GetTranslation.TryGetFromCoreDatabase, Sitecore.Kernel']" />
</getTranslation>
</pipelines>
</sitecore>
</configuration>
This is not a tested solution. Maybe give it a try and change the code as required.