Unwanted spaces appearing after HTML tags in translated text
How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!
While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.
legacy-article
learn-legacy-article-disclaimer-text
Issue
- When using HTML tags like <strong>, <b>, <h1>, <span>, and <i> within internationalized text in the Language Override functionality, an unnecessary space is generated after the closing tag when the text is rendered in a fragment
- This extra space is visible in both the displayed text and the translation list.
- The issue occurs if any character follows the closing HTML tag. If the translated text ends with the closing tag, the problem does not occur.
Environment
- Quarterly Releases
- DXP 2024.Q2, 2024.Q3
Resolution
- The issue is caused by the AntiSamy filter, that it is adding a carriage return after the HTML tags.
- To resolve the problem, disable the AntiSamy filter for Language Override functionality.
- Add
com.liferay.portal.language.override.model.PLOEntry to the AntiSamy whitelist.
- Go to the Control Panel > Configuration > System Settings.
- Navigate to Security Tools > AntiSamy Sanitizer
- Add a new entry for
com.liferay.portal.language.override.model.PLOEntry in the whitelist.
- Save your changes.
- For more information, se also: Spaces are removed from the translation when it is longer than 75 characters.
- Alternatively, you can create a custom AntiSamy policy specifically for
PLOEntry. This allows you to maintain AntiSamy functionality while addressing the space issue.
- To configure a custom policy:
- Review the documentation on using AntiSamy: Using AntiSamy
- Refer to LPS-112978 for a related issue and further context.
- Create a custom
sanitizer-configuration.xml file for PLOEntry. In this file, remove or modify the formatOutput instruction, which is responsible for adding the carriage return (and subsequently the extra space).
did-this-article-resolve-your-issue