import e from"i18next";import{useEffect as a}from"react";import{DEFAULT_LOCALE_PLACEHOLDER as s}from"../../../constants/common";import{defaultTranslationImports as l}from"../../../constants/l10n/default-translations";import{useL10nConfig as i}from"../hooks";const p=()=>{const{currentLocale:t}=i();a(()=>{const o=!t||t===s?"en":t;document.documentElement.setAttribute("lang",o)},[t])},g=async t=>{if(!t)return;const o=new Set(e.languages);for(const n of Object.keys(t.translations)){const r=await l[n]?.()||{};e.addResourceBundle(n,"translation",{...r,...t.translations[n]?.translation??{}},!0,!0),o.delete(n)}for(const n of o)e.removeResourceBundle(n,"translation")};export{g as updateTranslations,p as useL10n};
