Internationalization
TwistCal ships 12 languages with auto-detection. Force a language, or ship a single-language build to save ~2 KB.
TwistCal ships with 12 languages: English, German, Spanish, French, Italian, Portuguese, Dutch, Polish, Ukrainian, Russian, Japanese, Chinese.
Auto-detection priority
Language is auto-detected in this priority:
langattribute on<twist-cal>(e.g.lang="de")<html lang="...">attributenavigator.language- English fallback
<!-- Force German -->
<twist-cal lang="de" title="..." start="..." end="...">
</twist-cal>
<!-- Auto-detect from <html lang="ru"> -->
<twist-cal title="..." start="..." end="...">
</twist-cal>
Supported languages
| Code | Language |
|---|---|
en |
English |
de |
German |
es |
Spanish |
fr |
French |
it |
Italian |
pt |
Portuguese |
nl |
Dutch |
pl |
Polish |
uk |
Ukrainian |
ru |
Russian |
ja |
Japanese |
zh |
Chinese |
Single-language builds
For single-language sites, use dist/twistcal.{lang}.min.js — only that language is bundled, saving ~2 KB:
<script defer src="https://cdn.jsdelivr.net/npm/@freshjuice/twistcal/dist/twistcal.de.min.js"></script>
Available as full and slim:
| File | Size |
|---|---|
dist/twistcal.{lang}.min.js |
17 KB |
dist/twistcal.{lang}.slim.min.js |
9 KB |
Programmatic detection
import { detectLanguage, getTranslation, supportedLanguages } from '@freshjuice/twistcal';
detectLanguage('de'); // → 'de' (explicit wins)
detectLanguage(); // → auto-detected
getTranslation('fr'); // → { label: 'Ajouter au calendrier', services: { ... } }
supportedLanguages; // → ['en', 'de', 'es', 'fr', 'it', 'pt', 'nl', 'pl', 'uk', 'ru', 'ja', 'zh']
See API for the full function signatures.
