import o 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 u}from"../hooks";const p=()=>{const{currentLocale:t}=u();a(()=>{!t||t===s?document.documentElement.removeAttribute("lang"):document.documentElement.setAttribute("lang",t)},[t])},g=async t=>{if(!t)return;const n=new Set(o.languages);for(const e of Object.keys(t.translations)){const r=await l[e]?.()||{};o.addResourceBundle(e,"translation",{...r,...t.translations[e]?.translation??{}},!0,!0),n.delete(e)}for(const e of n)o.removeResourceBundle(e,"translation")};export{g as updateTranslations,p as useL10n};
