Home > widget-integration > FilterTranslationService > translate
FilterTranslationService.translate() method
Translates and updates the text content of an HTML element.
Convenience method that combines translateByKey and setElementText. Looks up the translation for the given key and applies it to the element.
Signature:
translate(element: HTMLElement, key?: string, defaultValue?: string): void;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
element |
HTMLElement |
The HTML element to update with translated text |
|
key |
string |
(Optional) The translation key, supports dot notation |
|
defaultValue |
string |
(Optional) Fallback text if translation key not found |
Returns:
void
Example
const titleElement = document.querySelector('.filter-title');
this.translate(titleElement, 'filter.title', 'Filters');