UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 1.47 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import{makeHandle as n}from"../core/handleUtils.js";let e,t;const o=globalThis.esriConfig?.locale??globalThis.dojoConfig?.locale,a=globalThis.document?.documentElement;function i(){const n=a?.getAttribute("lang"),e=globalThis.navigator?.language;return o??n??e??"en"}function r(){return void 0===t&&(t=i()),t}function c(n){e=n||void 0,v()}function s(n=r()){const e=/^([a-zA-Z]{2,3})(?:[_-][a-zA-Z0-9]+)*$/.exec(n);return e?.[1].toLowerCase()}const l=/^(?<language>[a-z]{2,3})(-(?<extlang>[a-z]{3}))?(-(?<script>[A-Z][a-z]{3}))?(-(?<region>[A-Z]{2}|\d{3}))?(-(?<variant>[a-zA-Z0-9]{5,8}|\d[a-zA-Z0-9]{3}))?(-x-(?<privateUse>[a-zA-Z0-9]{1,8}(-[a-zA-Z0-9]{1,8})*))?$/;function u(n=r()){return l.exec(n)?.groups}const g={he:!0,ar:!0};function f(n=r()){const e=s(n);return void 0!==e&&(g[e]||!1)}const d=[];function h(e){return d.push(e),n((()=>d.splice(d.indexOf(e),1)))}const b=[];function p(e){return b.push(e),n((()=>b.splice(b.indexOf(e),1)))}function v(){const n=e??i();t!==n&&([...b].forEach((e=>e(n))),t=n,[...d].forEach((e=>e(n))))}if(globalThis.addEventListener?.("languagechange",v),a){new MutationObserver((()=>{v()})).observe(a,{attributeFilter:["lang"]})}export{p as beforeLocaleChange,i as getDefaultLocale,s as getLanguage,r as getLocale,u as getLocaleParts,h as onLocaleChange,f as prefersRTL,c as setLocale};