The SiteLocaleAI JS library is a lightweight, zero-dependency script (~15KB gzipped) that you add to your HTML. It handles everything on the client side:
- Locale detection — Reads the visitor's browser language preferences and geo-IP data to determine their preferred language and currency.
- Translation requests — Sends page text to your SDK backend for translation. Only untranslated content is sent; cached translations are served instantly.
- DOM text swapping — Replaces visible text on the page with translated versions, preserving HTML structure, attributes, and event handlers.
- Price localization — Detects elements marked with
data-priceattributes and converts them to the visitor's local currency with proper formatting. - Language switcher — Renders an optional language picker UI that visitors can use to manually switch languages.