{"version":3,"sources":["Shared/Static/js/i18n.js"],"names":["define","require","_","_oMissingKeys","i18n","i18nDataField","document","getElementById","JSON","parse","value","lang","trans","raw","vars","tmpPrototypes","translatedString","text","m","constText","regex","exec","index","replace","replaceEscapedCharacters","split","length","counter","key","trim","charAt","isNumeric","String","parseInt","Object","keys","count","findCounter","i","contextualizedTrans","sTrans","constSTrans","DeserializeVars","fillVars","reverseEscapedCharacters","n","isNaN","parseFloat","isFinite","SS","ES","sNumericSet","sText","val","LN","RN","pluralIndex","serializedVars","newVars","varsList","v","i18nTrans","culture","$","locale","currentCulture","currentLocale","substring","flatpickrDateFormat","cleaveDateFormat","datePattern","delimiter","window","global_i18nMissingKeys","console","log","map","x","caller","join","i18nProxy","Proxy","location","hostname","fnShowMissingKeys","debounce","aoKeysNotShown","oCall","bShown","push","msg","take","panel","createElement","id","style","position","top","right","body","appendChild","pre","textContent","marginBottom","addEventListener","removeChild","childElementCount","displayMessage","trailing","get","target","name","receiver","sCaller","sCallStack","extractDirectCaller","Error","stack"],"mappings":"AAAAA,OAAO,SAAUC,SAChB,IAAIC,EAAID,QAAQ,UAEZE,KAEAC,KAEAC,EAAgBC,SAASC,eAAe,YACvB,MAAjBF,IACHD,EAAOI,KAAKC,MAAMJ,EAAcK,QAOrB,MAARN,IAAcA,MAElBA,EAAKO,KAAO,QACZP,EAAKQ,MAAQ,SAAUC,EAAKC,GAC3B,IAAIC,EACAC,EAiFJ,SAAkCC,GACjC,GAAY,MAARA,EAAc,CAMjBF,KAEA,IADA,IAAsBG,EAAlBC,EAAYF,EAASG,EAAQ,oCACM,QAA/BF,EAAIE,EAAMC,KAAKF,KACtBJ,EAAc,QAAUG,EAAEI,MAAQ,MAAQJ,EAAE,GAC5CD,EAAOA,EAAKM,QAAQL,EAAE,GAAI,QAAUA,EAAEI,MAAQ,MAIhD,OAAOL,EAhGeO,CAAyBX,GAAKY,MAAM,KACvDR,EAAO,KAEX,GAAID,EAAiBU,OAAS,EAAG,CAEhC,IAAI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lodash');\r\n\r\n\tvar _oMissingKeys = {};\r\n\r\n\tvar i18n = {};\r\n\r\n\tvar i18nDataField = document.getElementById('i18nData');\r\n\tif (i18nDataField != null) {\r\n\t\ti18n = JSON.parse(i18nDataField.value);\r\n\t}\r\n\telse {\r\n\t\t// le field i18nData est volontairement omis sur les sites seulement en FR\r\n\t\t// console.log(\"Le field i18nData est manquant (devrait être dans _Layout.vbhtml à la fin du body)\");\r\n\t}\r\n\r\n\tif (i18n == null) i18n = {};\r\n\r\n\ti18n.lang = 'fr-FR'//deprecated, utiliser i18n.culture() ou i18n.locale(). \r\n\ti18n.trans = function (raw, vars) {\r\n\t\tvar tmpPrototypes;\r\n\t\tvar translatedString = replaceEscapedCharacters(raw).split(\"|\");\r\n\t\tvar text = null;\r\n\r\n\t\tif (translatedString.length > 1) {\r\n\r\n\t\t\tvar counter = findCounter(vars);\r\n\r\n\t\t\tif (counter !== null && vars != null) {\r\n\t\t\t\tvar i = 0;\r\n\r\n\t\t\t\tfor (var i in translatedString) {\r\n\t\t\t\t\ttext = contextualizedTrans(translatedString[i], counter, i);\r\n\t\t\t\t\tif (text !== null)\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (text === null)\r\n\t\t\t\t\ttext = \"{ [i18n] ERROR: The translator couldn't find a suitable translate with the provided counter (counter: \" + counter + \", plainText: \" + raw + \").}\";\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\ttext = \"{ [i18n] ERROR: Counter not found.}\";\r\n\t\t}\r\n\t\telse\r\n\t\t\ttext = translatedString[0];\r\n\r\n\t\tif (text !== null) {\r\n\t\t\ttext = reverseEscapedCharacters(text);\r\n\t\t\ttext = fillVars(text, vars);\r\n\t\t\treturn text.trim();\r\n\t\t}\r\n\r\n\t\treturn null;\r\n\r\n\t\tfunction isNumeric(n) { return !isNaN(parseFloat(n)) && isFinite(n); }\r\n\r\n\t\tfunction findCounter(vars) {\r\n\t\t\tif (vars != null) {\r\n\t\t\t\tfor (var key in vars)\r\n\t\t\t\t\tif (key.trim().charAt(0) == '>' && isNumeric(String(vars[key]).trim()))\r\n\t\t\t\t\t\treturn parseInt(String(vars[key]).trim());\r\n\t\t\t\tif (Object.keys(vars).length == 1 && isNumeric(String(vars[Object.keys(vars)[0]]).trim()))\r\n\t\t\t\t\treturn parseInt(vars[Object.keys(vars)[0]]);\r\n\t\t\t\tif (typeof vars.count !== 'undefined' && isNumeric(String(vars.count).trim()))\r\n\t\t\t\t\treturn vars.count;\r\n\t\t\t}\r\n\t\t\treturn null;\r\n\t\t}\r\n\r\n\t\tfunction contextualizedTrans(translatedString, count, index) {\r\n\t\t\tif (count !== null) {\r\n\t\t\t\t/*var m, regex = /^\\s*([\\[\\]{])([^}\\[\\]]+)([\\]\\[}])\\s*(.*)$/g;*/\r\n\t\t\t\tvar m, regex = /(.*?)?\\s*([\\[\\]{])([^}\\[\\]]+)([\\]\\[}])\\s*(.*?)?$/g;\r\n\t\t\t\tif ((m = regex.exec(translatedString)) !== null) {\r\n\t\t\t\t\tvar SS = m[2];\r\n\t\t\t\t\tvar ES = m[4];\r\n\t\t\t\t\tvar sNumericSet = m[3];\r\n\t\t\t\t\tvar sText = (typeof m[5] == 'undefined') ? m[1] : m[5];\r\n\t\t\t\t\tif (SS == '{') {\r\n\t\t\t\t\t\tfor (var val in sNumericSet.split(','))\r\n\t\t\t\t\t\t\tif (val == count)\r\n\t\t\t\t\t\t\t\treturn (sText == '') ? ' ' : sText;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse {\r\n\t\t\t\t\t\tvar LN = sNumericSet.split(',')[0];\r\n\t\t\t\t\t\tvar RN = sNumericSet.split(',')[1];\r\n\t\t\t\t\t\tif (isNumeric(LN) && isNumeric(RN) && ((SS == ']' && (count > LN) || (SS == '[' && count >= LN)) && ((ES == ']' && count <= RN) || (ES == '[' && count < RN))))\r\n\t\t\t\t\t\t\treturn sText;\r\n\t\t\t\t\t\telse if (isNumeric(LN) && !isNumeric(RN) && ((SS == \"]\" && count > LN) || (SS == \"[\" && count >= LN)))\r\n\t\t\t\t\t\t\treturn sText;\r\n\t\t\t\t\t\telse if (!isNumeric(LN) && isNumeric(RN) && ((ES == \"]\" && count <= RN) || (ES == \"[\" && count < RN)))\r\n\t\t\t\t\t\t\treturn sText;\r\n\t\t\t\t\t\telse if (!isNumeric(LN) && !isNumeric(RN))\r\n\t\t\t\t\t\t\treturn sText;\r\n\t\t\t\t\t}\r\n\t\t\t\t\treturn null;\r\n\t\t\t\t}\r\n\t\t\t\treturn (pluralIndex(count) == index) ? translatedString : null;\r\n\t\t\t}\r\n\t\t\treturn null;\r\n\t\t}\r\n\r\n\t\tfunction replaceEscapedCharacters(text) {\r\n\t\t\tif (text != null) {\r\n\t\t\t\t/* Problem: can't find a way to replace \"\\\\|\" and \"\\|\" properly o_O... */\r\n\t\t\t\t//text = text.split('\\\\|').join('::KEEPBACKSLASH::|');\r\n\t\t\t\t//text = text.split('\\|').join('::KEEPVERTICALBAR::');\r\n\r\n\t\t\t\t// Some functions or variables may contain the character | but we don't want them to split the text so var's replace them and keep them in memory\r\n\t\t\t\ttmpPrototypes = {};\r\n\t\t\t\tvar constText = text, m, regex = /_\\(\\s*\\\"[^\"]+\"\\s*,?\\s*[^)]*\\s*\\)/g;\r\n\t\t\t\twhile ((m = regex.exec(constText)) !== null) {\r\n\t\t\t\t\ttmpPrototypes['::VAR' + m.index + '::'] = m[0];\r\n\t\t\t\t\ttext = text.replace(m[0], '::VAR' + m.index + '::');\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\treturn text;\r\n\t\t}\r\n\r\n\t\tfunction reverseEscapedCharacters(text) {\r\n\t\t\t//text = text.split('::KEEPBACKSLASH::').join('\\\\');\r\n\t\t\t//text = text.split('::KEEPVERTICALBAR::').join('|');\r\n\r\n\t\t\tfor (var i in tmpPrototypes)\r\n\t\t\t\ttext = text.replace(i, tmpPrototypes[i]);\r\n\r\n\t\t\treturn text;\r\n\t\t}\r\n\r\n\t\tfunction fillVars(sTrans, vars) {\r\n\t\t\tif (sTrans != null) {\r\n\t\t\t\tvar constSTrans = sTrans, m, regex = /(_|\\$)\\(\\s*(?:\"(.*?)\"\\s*,?)?\\s*([^)]*)\\s*\\)/g;\r\n\t\t\t\twhile ((m = regex.exec(constSTrans)) !== null)\r\n\t\t\t\t\tif (m[1] == '_' && typeof m[2] !== 'undefined')\r\n\t\t\t\t\t\tsTrans = sTrans.replace(m[0], i18n.trans(m[2].trim(), DeserializeVars(m[3], vars)));\r\n\t\t\t\t\telse if (m[1] == '$' && vars != null && (m[3] in vars))\r\n\t\t\t\t\t\tsTrans = sTrans.replace('$(' + m[3] + ')', vars[m[3]]);\r\n\t\t\t}\r\n\t\t\treturn sTrans;\r\n\t\t}\r\n\r\n\t\tfunction DeserializeVars(serializedVars, vars) {\r\n\t\t\tif (serializedVars !== \"\" && vars != null && Object.keys(vars).length > 0) {\r\n\t\t\t\tvar newVars = {}, varsList = serializedVars.split(',');\r\n\t\t\t\tfor (var v in varsList) {\r\n\t\t\t\t\tv = v.trim();\r\n\t\t\t\t\tnewVars[varsList[v]] = vars[varsList[v]];\r\n\t\t\t\t}\r\n\t\t\t\treturn newVars;\r\n\t\t\t}\r\n\t\t\treturn vars;\r\n\t\t}\r\n\r\n\r\n\t\tfunction pluralIndex(count) {\r\n\t\t\treturn (count == 0) ? 0 : (count == 1 || count == -1) ? 1 : 2;\r\n\t\t}\r\n\t};\r\n\ti18n.i18nTrans = i18n.trans; // keep compatibility\r\n\r\n\r\n\ti18n.culture = function () {\r\n\t\treturn $(\"#currentCulture\").val();\r\n\t}\r\n\r\n\t//locale = les 2 premiers lettres de la culture\r\n\ti18n.locale = function () {\r\n\t\tvar currentCulture = $(\"#currentCulture\").val();\r\n\t\tvar currentLocale = \"fr\";\r\n\r\n\t\tif (currentCulture && currentCulture.length) {\r\n\t\t\tcurrentLocale = currentCulture.substring(0, 2);\r\n\t\t}\r\n\t\treturn currentLocale;\r\n\t}\r\n\r\n\t// https://en.wikipedia.org/wiki/Date_format_by_country\r\n\t// https://flatpickr.js.org/formatting/\r\n\ti18n.flatpickrDateFormat = function () {\r\n\t\tswitch (i18n.locale()) {\r\n\t\t\tcase \"fr\": return \"d/m/Y\";\t// dd/mm/yyyy\r\n\t\t\tcase \"it\": return \"d/m/Y\";\t// dd/mm/yyyy\r\n\t\t\tcase \"en\": return \"m/d/Y\";\t// mm/dd/yyyy\r\n\t\t\tcase \"nl\": return \"d-m-Y\";\t// dd-mm-yyyy\r\n\t\t}\r\n\r\n\t\t// fr par default\r\n\t\treturn \"d/m/Y\";\t// dd/mm/yyyy\r\n\t}\r\n\r\n\t// https://en.wikipedia.org/wiki/Date_format_by_country\r\n\t// https://github.com/nosir/cleave.js/blob/master/doc/options.md#datepattern\r\n\t// https://github.com/nosir/cleave.js/blob/master/doc/options.md#delimiter\r\n\ti18n.cleaveDateFormat = function () {\r\n\t\tswitch (i18n.locale()) {\r\n\r\n\t\t\tcase \"fr\": return { datePattern: ['d', 'm', 'Y'], delimiter: '/' };\t// dd/mm/yyyy\r\n\t\t\tcase \"it\": return { datePattern: ['d', 'm', 'Y'], delimiter: '/' };\t// dd/mm/yyyy\r\n\t\t\tcase \"en\": return { datePattern: ['m', 'd', 'Y'], delimiter: '/' };\t// mm/dd/yyyy\r\n\t\t\tcase \"nl\": return { datePattern: ['d', 'm', 'Y'], delimiter: '-' };\t// dd-mm-yyyy\r\n\t\t}\r\n\r\n\t\t// fr par default\r\n\t\treturn { datePattern: ['d', 'm', 'Y'], delimiter: '/' };\t// dd/mm/yyyy\r\n\t}\r\n\r\n\r\n\twindow.global_i18nMissingKeys = function () {\r\n\t\treturn console.log(Object.keys(_oMissingKeys)\r\n\t\t\t.map(function (x) { return _oMissingKeys[x]; })\r\n\t\t\t.map(function (x) { return x.key + \"\\t\" + x.caller; })\r\n\t\t\t.join(\"\\n\"));\r\n\t}\r\n\r\n\r\n\t//en local, intercepte les appels à i18n qui n'ont pas de traduction\r\n\tvar i18nProxy = null;\r\n\tif (window.Proxy && window.location.hostname == 'localhost') {\r\n\r\n\t\tfunction displayMessage(msg) {\r\n\r\n\t\t\tvar panel = document.getElementById('missing_i18n_keys')\r\n\t\t\tif (!panel) {\r\n\t\t\t\tpanel = document.createElement(\"div\");\r\n\t\t\t\tpanel.id = 'missing_i18n_keys';\r\n\t\t\t\tpanel.style.position = \"fixed\";\r\n\t\t\t\tpanel.style.top = 0;\r\n\t\t\t\tpanel.style.right = 0;\r\n\t\t\t\tdocument.body.appendChild(panel);\r\n\t\t\t}\r\n\r\n\t\t\tvar pre = document.createElement(\"pre\");\r\n\t\t\tpre.textContent = msg + \"\\n\\t...click to close\";\r\n\t\t\tpre.style.marginBottom = \"5px\";\r\n\t\t\tpre.addEventListener('click', function () {\r\n\t\t\t\tpanel.removeChild(pre);\r\n\t\t\t\tif (!panel.childElementCount) {\r\n\t\t\t\t\tdocument.body.removeChild(panel);\r\n\t\t\t\t}\r\n\r\n\t\t\t});\r\n\r\n\r\n\t\t\tpanel.appendChild(pre);\r\n\t\t}\r\n\r\n\t\tfunction extractDirectCaller(sCallStack) {\r\n\t\t\tif (sCallStack) {\r\n\t\t\t\tvar asLines = sCallStack.split(\"\\n\");\r\n\t\t\t\t//line 0 = 'Error'\r\n\t\t\t\t//line 1 = \"at Object.get from i18n.js\"\r\n\t\t\t\t//line 2 = relevant caller\r\n\t\t\t\treturn asLines[2];\r\n\r\n\t\t\t}\r\n\r\n\t\t\treturn '';\r\n\t\t}\r\n\r\n\t\tvar fnShowMissingKeys = _.debounce(function () {\r\n\t\t\tvar aoKeysNotShown = [];\r\n\t\t\tfor (var key in _oMissingKeys) {\r\n\t\t\t\tvar oCall = _oMissingKeys[key];\r\n\t\t\t\tif (!oCall.bShown) {\r\n\t\t\t\t\taoKeysNotShown.push(oCall);\r\n\t\t\t\t\t//marque la propriété comme affichée dans les erreurs\r\n\t\t\t\t\toCall.bShown = true;;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (aoKeysNotShown.length) {\r\n\t\t\t\tconsole.log(\"Missing i18n keys :\\n\", aoKeysNotShown.map(function (x) { return x.key + \"\\t\" + x.caller }).join(\"\\n\"));\r\n\r\n\t\t\t\tvar msg = \"Missing i18n keys :\\n\" + _.take(aoKeysNotShown, 5).map(function (x) { return x.key }).join(\"\\n\");\r\n\t\t\t\tif (aoKeysNotShown.length > 5) {\r\n\t\t\t\t\tmsg + \"\\n(\" + (aoKeysNotShown.length - 5) + \" more in console)\";\r\n\t\t\t\t}\r\n\r\n\t\t\t\tdisplayMessage(msg);\r\n\t\t\t}\r\n\r\n\t\t}, 500, { trailing: true });\r\n\r\n\t\ti18nProxy = new Proxy(i18n,\r\n\t\t\t{\r\n\t\t\t\tget: function (target, name, receiver) {\r\n\t\t\t\t\tif (name in target) {\r\n\t\t\t\t\t\treturn target[name];\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (!(name in _oMissingKeys)) {\r\n\t\t\t\t\t\t//extract caller\r\n\t\t\t\t\t\tvar sCaller = extractDirectCaller(new Error().stack);\r\n\r\n\r\n\t\t\t\t\t\t_oMissingKeys[name] = { key: name, bShown: false, caller: sCaller };\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tfnShowMissingKeys();\r\n\r\n\t\t\t\t\treturn undefined;\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t}\r\n\r\n\treturn i18nProxy || i18n;\r\n});\r\n"]}