Home > widget-integration > FilterTranslationService > applyTranslationsToFilterOptions
FilterTranslationService.applyTranslationsToFilterOptions() method
Applies translations to all filter options in the current filter state.
Iterates through all filter options in the filter state, retrieves their translated labels, sanitizes them for XSS prevention (unless disabled in config), and updates the corresponding DOM elements. Finally updates the filter state with the translated labels.
Signature:
applyTranslationsToFilterOptions(): void;
Returns:
void
Remarks
This method performs DOM queries for each filter option using generated selectors. XSS sanitization is applied via FilterHelper unless explicitly disabled in TAEAppConfig.xss.filter.disabled. The method updates both the DOM elements and the filter state in the store.
Example 1
Basic usage:
// Called after filter options are loaded
this.applyTranslationsToFilterOptions();
Example 2
Extend to add performance optimization:
window.boostWidgetIntegration.extend('FilterTranslationService', (FilterTranslationService) => {
return class CustomFilterTranslationService extends FilterTranslationService {
applyTranslationsToFilterOptions() {
const startTime = performance.now();
super.applyTranslationsToFilterOptions();
const duration = performance.now() - startTime;
if (duration > 100) {
console.warn(`Slow translation application: ${duration}ms`);
}
}
};
});