Everything you need to integrate AI-powered translation into your website
Get started with Multilingua.js in less than 5 minutes.
Add the Multilingua widget to your HTML file:
Mark elements you want to translate with data-i18n attribute:
Open your page and click the language selector that appears in the top-right corner. Select a language and watch your content translate instantly!
💡 Note: Each unique translation costs approximately $0.001-0.002. Translations are cached automatically to minimize costs.
Customize the widget behavior with these options:
| Option | Type | Default | Description |
|---|---|---|---|
apiBaseUrl |
string | 'https://multilingua.ai' |
Base URL for API calls (default: multilingua.ai) |
position |
string | 'top-right' |
Widget position: 'top-right', 'top-left', 'bottom-right', 'bottom-left' |
mainLanguages |
array | ['gb', 'it', ...] |
Array of country codes to show in main menu |
defaultLanguage |
string | 'gb' |
Default language code |
apiKey |
string | null |
Your Multilingua API key (optional for demo) |
Example with all options:
Programmatically translate page to specified language code
Returns the currently active language code
Removes the widget and cleans up event listeners
Usage example:
The widget triggers custom events on the document:
| Event | When | Event Data |
|---|---|---|
multilingua:start |
Translation starts | { language: 'it' } |
multilingua:complete |
Translation completes | { language: 'it', count: 42 } |
multilingua:error |
Translation fails | { error: 'message' } |
Listen to events:
Use meaningful data-i18n values like "hero-title" instead of "h1" for better organization
Translations are automatically cached in localStorage to minimize API calls and costs
Write clear, natural text in your default language for better AI translation quality
Review translations in different languages to ensure quality and context accuracy
Each unique translation costs approximately $0.001-0.002. Once translated, content is cached automatically, so returning visitors won't trigger new API calls.
Over 250 languages are supported, from major world languages to regional dialects. The widget includes flags for the most common languages.
For demo and testing purposes, no API key is required. For production use with higher volume, you'll need to register for an API key on our website.
Yes! Simply add the data-i18n attribute to new elements and call the translate() method again with the current language code.
We use state-of-the-art neural machine translation models that understand context, technical terminology, and maintain natural language flow. Quality is comparable to professional human translation for most content.
Need help or have questions? We're here to assist you.
Report bugs or request features on our GitHub repository
Contact us at support@multilingua.dev for technical assistance
Check this page for detailed guides and API reference