Projects

Translation Module for Tilda

Client-side RU↔EN switcher for Tilda websites with a local dictionary, MyMemory/LibreTranslate fallback, and bilingual search.

  • JavaScript
  • Tilda
  • LocalStorage
  • MutationObserver

The module enables in-browser language switching (RU → EN) without page reload. The script is compiled into a single minified IIFE bundle and embedded into Tilda via the Custom JS field. On clicking EN, all text nodes and attributes (placeholder, value) inside Tilda content blocks are traversed; translations are pulled from a local dictionary, and when a key is missing, from MyMemory API and LibreTranslate in sequence. Results are cached in localStorage to avoid redundant network requests.

Technical decisions

The original Russian text is stored in data-attributes on each element, so switching back to RU is instant with no re-traversal. A MutationObserver automatically translates dynamically added content — popups, sliders, accordions — without extra integration. The matching algorithm builds two indexes: forward (RU→EN) and reverse (EN→RU), with keys sorted by descending length to prevent partial replacement of longer phrases.

Bilingual search

For product catalogs, a bilingual search mode adds a hidden span with RU and EN aliases to each card title. User queries in Cyrillic are automatically normalised to Latin via the dictionary with an API fallback. The dictionary is extensible without touching code — via Google Sheets CSV sync with a configurable TTL.