MCPcopy
hub / github.com/orestbida/cookieconsent / resolveCurrentLanguageCode

Function resolveCurrentLanguageCode

src/utils/language.js:73–97  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

71 * @returns {string} language code
72 */
73export const resolveCurrentLanguageCode = () => {
74 const autoDetect = globalObj._state._userConfig.language.autoDetect;
75
76 if (autoDetect) {
77 debug('CookieConsent [LANG]: autoDetect strategy: "' + autoDetect + '"');
78
79 const detectionStrategies = {
80 browser: getBrowserLanguageCode(),
81 document: getDocumentLanguageCode()
82 };
83
84 /**
85 * @type {string}
86 */
87 const newLanguageCode = getAvailableLanguage(detectionStrategies[autoDetect]);
88
89 if (newLanguageCode)
90 return newLanguageCode;
91 }
92
93 /**
94 * Use current language
95 */
96 return getCurrentLanguageCode();
97};
98
99/**
100 * Load translation

Callers 2

setConfigFunction · 0.90
language.test.jsFile · 0.90

Calls 5

debugFunction · 0.90
getBrowserLanguageCodeFunction · 0.85
getDocumentLanguageCodeFunction · 0.85
getAvailableLanguageFunction · 0.85
getCurrentLanguageCodeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…