window.resetTranslation() to restore the page to a specified language. This is typically used to return the page to its source language after a translation has been applied.
When called, it restores the original text from data-original-text attributes stored on each translated element, restores any adjusted font sizes to their original values, and clears the active translation state.
Signature
Parameters
The language code to reset to. This should typically be your page’s source language (e.g.,
"en" for English). The value is passed back in the onComplete callback to confirm which language was reset to.Callback called when the reset completes. Receives an object with
success (boolean) and targetLanguage (string).Callback called if the reset fails. Receives an
Error object.Return value
This function returnsvoid. Use the onComplete callback or handle the side effects directly.
Example
What reset does
When you callwindow.resetTranslation(), the widget:
- Reads the
data-original-textattribute on every translated element and restores the original text content. - Restores the original font size for any element whose font size was adjusted during translation.
- Removes the
data-original-text,data-translated-lang, anddata-original-font-sizeattributes from all elements. - Clears the internal translation state so the widget is ready for a fresh translation.
This overrides any earlier translation and returns all page content to the original language. If the widget has not translated the page yet, calling
window.resetTranslation() has no visible effect.