Skip to content

Internationalization

The SpartanAuth widgets support four languages out of the box. Set the locale attribute to switch the UI language.

CodeLanguage
enEnglish (default)
frFrench
esSpanish
jaJapanese
<spartan-login
locale="fr"
domain="https://api.spartanauth.com"
sector="your-sector-id">
</spartan-login>
const locale = navigator.language.slice(0, 2) || 'en';
// e.g. "en", "fr", "es", "ja"

Fall back to 'en' for any unsupported language codes.

The widget reads its locale once at initialization. Changing the locale attribute after the widget is mounted has no effect. To switch languages, you must force the widget to remount.

const locale = ref(navigator.language.slice(0, 2) || 'en');
const widgetKey = ref(0);
// Force a remount whenever locale changes
watch(locale, () => { widgetKey.value++; });
<spartan-login :key="widgetKey" :locale="locale" ...></spartan-login>
const [locale, setLocale] = useState(navigator.language.slice(0, 2) || 'en');
const [widgetKey, setWidgetKey] = useState(0);
function changeLocale(newLocale: string) {
setLocale(newLocale);
setWidgetKey(k => k + 1); // forces remount
}
<spartan-login key={widgetKey} locale={locale} ...></spartan-login>
<template>
<div>
<select v-model="locale">
<option value="en">English</option>
<option value="fr">Français</option>
<option value="es">Español</option>
<option value="ja">日本語</option>
</select>
<spartan-login
:key="widgetKey"
:locale="locale"
domain="https://api.spartanauth.com"
sector="your-sector-id">
</spartan-login>
</div>
</template>
<script setup lang="ts">
import { ref, watch } from 'vue';
const locale = ref('en');
const widgetKey = ref(0);
watch(locale, () => { widgetKey.value++; });
</script>