MCPcopy Create free account
hub / github.com/microsoft/SandDance / getLanguage

Function getLanguage

docs/app/js/sanddance-app.js:25491–25501  ·  view source on GitHub ↗
(persistenceType)

Source from the content-addressed store, hash-verified

25489var _language;
25490var STORAGE_KEY = "language";
25491function getLanguage(persistenceType) {
25492 if (persistenceType === void 0) persistenceType = "localStorage";
25493 if (_language === undefined) {
25494 var doc = (0, _getDocument.getDocument)();
25495 var savedLanguage = persistenceType === "localStorage" ? _localStorage.getItem(STORAGE_KEY) : persistenceType === "sessionStorage" ? _sessionStorage.getItem(STORAGE_KEY) : undefined;
25496 if (savedLanguage) _language = savedLanguage;
25497 if (_language === undefined && doc) _language = doc.documentElement.getAttribute("lang");
25498 if (_language === undefined) _language = "en";
25499 }
25500 return _language;
25501}
25502function setLanguage(language, persistenceParam) {
25503 var doc = (0, _getDocument.getDocument)();
25504 if (doc) doc.documentElement.setAttribute("lang", language);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected