import n from"i18next";import{useEffect as r}from"react";import{DEFAULT_LOCALE_PLACEHOLDER as a}from"../../../constants/index.js";import{useGlobalData as i}from"../useGlobalData";import{useL10nConfig as m}from"../hooks";import{isBrowser as l}from"../../../shared/jsUtils";import{initL10n as s}from"../../../shared/l10n/initL10n";const E=()=>{const{l10n:e}=i()||{},{currentLocale:t}=m();r(()=>{s(e,t)},[]),r(()=>{!t||t===a?document.documentElement.removeAttribute("lang"):document.documentElement.setAttribute("lang",t)},[t]),l()||s(e,t)},A=e=>{if(!e)return;const t=new Set(n.languages);for(const o of Object.keys(e.translations))n.addResourceBundle(o,"translation",e.translations[o].translation,!0,!0),t.delete(o);for(const o of t)n.removeResourceBundle(o,"translation")};export{A as updateTranslations,E as useL10n};
