Home›Support›English Support›[Resolved] I need help preventing WPML from altering specific characters (such as the en dash “–”) during...
[Resolved] I need help preventing WPML from altering specific characters (such as the en dash “–”) during...
This thread is resolved. Here is a description of the problem and solution.
Problem: The client is experiencing an issue where special characters like the en dash (–) are being replaced by a regular hyphen (-) in translations using WPML. This alteration occurs regardless of the translation method used, affecting the intended formatting of product titles and descriptions.
Solution: We conducted detailed tests using both automatic and manual translations across different language pairs and translation services. Here are the findings: 1. When using PTC for translations, the issue does not occur. The en dash remains unchanged in both the Advanced Translation Editor (ATE) and on the frontend. 2. When using DeepL, the en dash is replaced by a regular hyphen in the ATE, but it displays correctly as an en dash on the frontend. This inconsistency is due to DeepL's internal grammar rules, which we cannot alter.
If this solution does not resolve your issue or seems outdated, we recommend opening a new support ticket. Additionally, please check the related known issues, verify the version of the permanent fix, and confirm that you have installed the latest versions of themes and plugins. For further assistance, visit our support forum.
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
Background of the issue:
I am trying to translate product titles and descriptions using WPML, while keeping special characters like the en dash (–) unchanged. You can see the issue on this page: hidden link.
Symptoms:
The en dash (–, Unicode U+2013) is automatically replaced by a regular hyphen (-, ASCII 0x2D) in the translated content, which alters the intended formatting.
Questions:
How can I prevent WPML from altering specific characters like the en dash during translation?
1- Get access to your website files.
2- Go to \WPML_Super_Globals_Validation::get_value in wp-content/plugins/sitepress-multilingual-cms/classes/request-handling/class-wpml-super-globals-validation.php
3- change the following code:
Hi,
Thank you for your reply and for providing the suggested code modification.
Unfortunately, after applying the change as instructed, the issue still persists: the en dash character (–) is still being replaced by a regular hyphen (-) in the translated content.
Could you please advise on the next steps or provide an alternative solution to ensure that the en dash (–, Unicode U+2013) is preserved exactly as in the source text during translation?
I can provide additional examples or screenshots if needed.
Best regards,
I tested this in very much detail using automatic translation, as well as, manual but auto-translated within the ATE. I also tested from English (default) to French and Italian (secondary), as well as, French (default) to English & Italian (secondary).
Further I tested using DeepL default formality and formal/informal formalities, as well as, with PTC auto-formality. Here are my findings:
- Using PTC: Issue doesn't happen at all. After translating if you open the translation in ATE, you can see the same – in the translation too.
- Using DeepL: Regardless of the formality, you can see - instead of – in the translation. However, this does not affect the translation on frontend. For example, if you check this Italian translation hidden link and then check the translation in ATE, you'll notice that – works fine on frontend, although ATE shows - in the translation.
You can use this sandbox site (hidden link - one click login) and try it. This setup is using minimal setup (i.e. WPML, String Translation and a default WordPress theme).
...this is a known issue. some special characters are changed because DeepL thinks it's needed. it's supposed to be a grammar thing, that's supposed to be the correct translation.
that can't be fixed because it comes from deepl (we've tried asking many times already).