Internationalization (i18n)
Configure multi-language support for the SeggWat feedback widget
Overview
The SeggWat feedback widget supports multiple languages to provide a localized experience for your users. Language detection happens automatically based on the user's browser settings, or you can specify a language explicitly.
Supported Languages
🇬🇧 English
Code: en (default)
🇩🇪 German
Code: de
🇸🇪 Swedish
Code: sv
Usage
Automatic Detection
By default, the widget automatically detects the user's browser language:
If the user's browser is set to German (de-DE), the widget will display in German. If the browser language is not supported, English is used as a fallback.
Manual Language Selection
Explicitly set the language using the data-language attribute:
<!-- German -->
<!-- Swedish -->
<!-- English (explicit) -->
Translated Strings
All UI elements are translated, including:
| Element | English | German | Swedish |
|---|---|---|---|
| Button | Feedback | Feedback | Feedback |
| Modal Title | Send Feedback | Feedback senden | Skicka feedback |
| Modal Subtitle | We'd love to hear your thoughts! | Wir freuen uns auf Ihr Feedback! | Vi skulle gärna höra dina tankar! |
| Label | Your Feedback | Ihr Feedback | Din feedback |
| Placeholder | Tell us what you think... | Sagen Sie uns, was Sie denken... | Berätta vad du tycker... |
| Cancel Button | Cancel | Abbrechen | Avbryt |
| Submit Button | Send Feedback | Feedback senden | Skicka feedback |
| Sending... | Sending... | Wird gesendet... | Skickar... |
| Success | Thank you for your feedback! | Vielen Dank für Ihr Feedback! | Tack för din feedback! |
| Error | Sorry, there was an error... | Entschuldigung, beim Senden... | Tyvärr uppstod ett fel... |
How It Works
Language Detection Flow
graph TD
A[Widget Loads] --> B{data-language set?}
B -->|Yes| C[Use specified language]
B -->|No| D[Detect browser language]
D --> E{Language supported?}
E -->|Yes| F[Use detected language]
E -->|No| G[Fallback to English]
C --> H{Language file exists?}
H -->|Yes| I[Load translations]
H -->|No| G
F --> I
G --> I
I --> J[Render widget]Translation Loading
- Detection: The widget determines the language from
data-languageornavigator.language - Validation: Checks if the language is in the supported list (
en,de,sv) - Fetching: Loads the translation file from
/static/i18n/{lang}.json - Fallback: If loading fails, uses hardcoded English translations
- Rendering: Displays the widget with translated text
Dynamic Language Updates
You can change the widget language after initialization without reloading the page:
// Switch to German
window..;
// Switch to Swedish
window..;
// Switch back to English
window..;This is useful for sites with a language picker. When users change their language preference, you can update the feedback widget to match without reloading the page.
Example: Language Switcher Integration
English
Deutsch
Svenska
The language change is asynchronous as it fetches new translation files. All UI text updates automatically, including the button text, modal title, labels, and messages.
Examples
Multi-language Website
Serve different languages based on your site's current locale:
<!-- German page -->
<!-- Swedish page -->
