How to Prevent GTranslate from Translating Numbers, Dates, and Specific Text
Content
A common challenge for users of the 'Translate WordPress with GTranslate' plugin is its tendency to automatically translate content that should remain unchanged. Based on community reports, this frequently affects numbers, dates, brand names, acronyms, and other specific text snippets, leading to broken functionality or confusing user experiences.
Why Does This Happen?
The 'Translate WordPress with GTranslate' plugin uses automated machine translation to process page content. This system is designed to translate all text it encounters. Consequently, it can misinterpret numerical data, dates, and specialized terminology (like 'A-Z' becoming 'Arizona' or 'XMAS' becoming 'Potatoes') as words that need to be translated into the target language.
The Most Common Solution: The 'notranslate' Class
The primary method to prevent unwanted translations is to use the notranslate HTML class. This class acts as a signal to the translation engine to skip the enclosed content.
How to Implement It:
- Identify the Element: Use your browser's inspector tool to find the HTML element containing the text you want to protect (e.g., a
<span>,<div>, or<td>). - Add the Class: Modify the element's code to include
class="notranslate".
Example 1: Protecting a Number in a Table
Before: <td>18.00</td>
After: <td class="notranslate">18.00</td>
Example 2: Protecting a Brand Name in a Title Tag
Before: <span>MyBrandName</span>
After: <span class="notranslate">MyBrandName</span>
Example 3: Protecting a Date Picker (via JavaScript)
If you cannot edit the source HTML directly, you can use JavaScript to add the class after the page loads:
document.querySelector('#your-date-picker-id').classList.add('notranslate');
Important Considerations
- Wrapper Elements: For dynamic elements or complex features like calendar date pickers, adding the
notranslateclass to a parent wrapper element is often more effective than targeting individual numbers. - Limitations of the Free Version: The 'notranslate' class is the main solution provided for the free version of the plugin. As noted in many support threads, the team behind 'Translate WordPress with GTranslate' often suggests that their paid version may handle these issues 'out of the box' without requiring manual code changes.
- Automatic Translation Quirks: Some translation oddities, like certain text being converted to uppercase in specific languages, may be a result of the underlying Google Translate engine and cannot always be fixed with CSS or the
notranslateclass.
By strategically using the notranslate class, you can gain greater control over what gets translated, ensuring that critical data and branding remain consistent across all languages on your site.
Related Support Threads Support
-
Number 16 in numeral when translated into Spanish it changes to the wordhttps://wordpress.org/support/topic/number-16-in-numeral-when-translated-into-spanish-it-changes-to-the-word/
-
duplicate folder name for alternative hreflang tag URL…https://wordpress.org/support/topic/duplicate-folder-name-for-alternative-hreflang-tag-url/
-
Linking to pdfshttps://wordpress.org/support/topic/linking-to-pdfs/
-
Inconsistent Text Translation Formatting in Pluginhttps://wordpress.org/support/topic/inconsistent-text-translation-formatting-in-plugin/
-
calendar translate issuehttps://wordpress.org/support/topic/traducion-del-calendario/
-
Plugin is translating emails – how to prevent?https://wordpress.org/support/topic/plugin-is-translating-emails-how-to-prevent/
-
GTranslate translating number “2” for “two”https://wordpress.org/support/topic/gtranslate-translating-number-2-for-two/
-
Strange Behavior | Calendar Numbers Translated Into Wordshttps://wordpress.org/support/topic/strange-behavior-calendar-numbers-translated-into-words/
-
Translation of domain nameshttps://wordpress.org/support/topic/translation-of-domain-names/
-
GTranslate date number “21-24” from Chinese to English issuehttps://wordpress.org/support/topic/gtranslate-date-number-21-24-from-chinese-to-english-issue/
-
Dollar sign changes to “ps” in GiveWP pluginhttps://wordpress.org/support/topic/dollar-sign-changes-to-ps-in-givewp-plugin/
-
GTranslate showing incorrect URL in HREFLANGhttps://wordpress.org/support/topic/gtranslate-showing-incorrect-url-in-hreflang/
-
Float values converted into time values after translationhttps://wordpress.org/support/topic/float-values-converted-into-time-values-after-translation/
-
Number in booking calendar is translated into wordhttps://wordpress.org/support/topic/number-in-boobking-calendar-translated-into-word/
-
the html id notranslate creates inconsistencies in translationshttps://wordpress.org/support/topic/the-html-id-notranslate-creates-inconsistencies-in-translations/
-
Time Format Issuehttps://wordpress.org/support/topic/time-format-issue-2/
-
Exclude dynamic URLs in scriptshttps://wordpress.org/support/topic/exclude-dynamic-urls-in-scripts/
-
Google Not Recognizing Language Pageshttps://wordpress.org/support/topic/google-not-recognizing-language-pages/
-
Canonical Issueshttps://wordpress.org/support/topic/canonical-issues-2/
-
GTranslate and HBookhttps://wordpress.org/support/topic/gtranslate-and-hbook/
-
“A-Z” alpha link translates as “Arizona”https://wordpress.org/support/topic/a-z-alpha-link-translates-as-arizona/
-
Incorrect DOM conversion on Frontendhttps://wordpress.org/support/topic/incorrect-dom-conversion-on-frontend/
-
Prohibition of translation link on my website errorhttps://wordpress.org/support/topic/prohibition-of-translation-link-on-my-website-error/
-
wp-json request translatedhttps://wordpress.org/support/topic/wp-json-request-translated/
-
Links translate problemhttps://wordpress.org/support/topic/links-translate-problem/
-
Sub-directory URL and Gravity Form File Uploadhttps://wordpress.org/support/topic/sub-directory-url-and-gravity-form-file-upload/
-
Translating e-mailaddress?https://wordpress.org/support/topic/translating-e-mailaddress/
-
404 page Tag problemhttps://wordpress.org/support/topic/404-page-tag-problem/
-
Spanish Only | Title Case Converted to Upper Casehttps://wordpress.org/support/topic/spanish-only-title-case-converted-to-upper-case/
-
hreflang conflictshttps://wordpress.org/support/topic/hreflang-conflicts/
-
Eror Datehttps://wordpress.org/support/topic/eror-date/
-
Números traducidoshttps://wordpress.org/support/topic/numeros-traducidos/
-
パスワード保護ページにログイン後エラーが発生するhttps://wordpress.org/support/topic/%e3%83%91%e3%82%b9%e3%83%af%e3%83%bc%e3%83%89%e4%bf%9d%e8%ad%b7%e3%83%9a%e3%83%bc%e3%82%b8%e3%81%ab%e3%83%ad%e3%82%b0%e3%82%a4%e3%83%b3%e5%be%8c%e3%82%a8%e3%83%a9%e3%83%bc%e3%81%8c%e7%99%ba%e7%94%9f/
-
GT translate translate the title taghttps://wordpress.org/support/topic/gt-translate-translate-the-title-tag/
-
Issue with different language translationshttps://wordpress.org/support/topic/issue-with-different-language-translations/
-
XMAS translated as ‘Potatoes’ in page title using Google Translate pluginhttps://wordpress.org/support/topic/xmas-translated-as-potatoes-in-page-title-using-google-translate-plugin/