UNPKG

@vaadin/hilla-react-i18n

Version:

Hilla I18n utils for React

21 lines 660 B
export class DefaultBackend { async loadTranslations(language, chunks, keys) { const params = new URLSearchParams([ ["v-r", "i18n"], ["langtag", language], ...(chunks ?? []).map((chunk) => ["chunks", chunk]), ...(keys ?? []).map((key) => ["keys", key]) ]); const response = await fetch(`./?${params.toString()}`); if (!response.ok) { throw new Error("Failed fetching translations."); } const retrievedLocale = response.headers.get("X-Vaadin-Retrieved-Locale"); const translations = await response.json(); return { translations, resolvedLanguage: retrievedLocale ?? undefined }; } } //# sourceMappingURL=./backend.js.map