From 29609dbc67e8aa51679d04c9150a3d3fb75ade7f Mon Sep 17 00:00:00 2001 From: Philippe Loctaux Date: Sun, 6 Aug 2023 17:52:22 +0200 Subject: [PATCH 01/11] added i18next, translated header --- .../i18nextBrowserLanguageDetector.min.js | 2 ++ .../i18nextHttpBackend.min.js | 2 ++ .../ezidam/static/libs/i18next/i18next.min.js | 2 ++ .../libs/loc-i18next/loc-i18next.min.js | 2 ++ crates/ezidam/templates/base.html.tera | 36 ++++++++++++++++++- crates/ezidam/templates/shell.html.tera | 4 +++ .../ezidam/templates/shell/header.html.tera | 8 ++--- 7 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 crates/ezidam/static/libs/i18next-browser-language-detector/i18nextBrowserLanguageDetector.min.js create mode 100644 crates/ezidam/static/libs/i18next-http-backend/i18nextHttpBackend.min.js create mode 100644 crates/ezidam/static/libs/i18next/i18next.min.js create mode 100644 crates/ezidam/static/libs/loc-i18next/loc-i18next.min.js diff --git a/crates/ezidam/static/libs/i18next-browser-language-detector/i18nextBrowserLanguageDetector.min.js b/crates/ezidam/static/libs/i18next-browser-language-detector/i18nextBrowserLanguageDetector.min.js new file mode 100644 index 0000000..b332ae8 --- /dev/null +++ b/crates/ezidam/static/libs/i18next-browser-language-detector/i18nextBrowserLanguageDetector.min.js @@ -0,0 +1,2 @@ +// https://unpkg.com/i18next-browser-languagedetector@7.1.0/i18nextBrowserLanguageDetector.min.js +!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):(e="undefined"!=typeof globalThis?globalThis:e||self).i18nextBrowserLanguageDetector=o()}(this,(function(){"use strict";function e(e,o){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function t(e){var t=function(e,t){if("object"!==o(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!==o(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===o(t)?t:String(t)}function n(e,o){for(var n=0;n0){var a=n.maxAge-0;if(Number.isNaN(a))throw new Error("maxAge should be a Number");r+="; Max-Age=".concat(Math.floor(a))}if(n.domain){if(!s.test(n.domain))throw new TypeError("option domain is invalid");r+="; Domain=".concat(n.domain)}if(n.path){if(!s.test(n.path))throw new TypeError("option path is invalid");r+="; Path=".concat(n.path)}if(n.expires){if("function"!=typeof n.expires.toUTCString)throw new TypeError("option expires is invalid");r+="; Expires=".concat(n.expires.toUTCString())}if(n.httpOnly&&(r+="; HttpOnly"),n.secure&&(r+="; Secure"),n.sameSite)switch("string"==typeof n.sameSite?n.sameSite.toLowerCase():n.sameSite){case!0:r+="; SameSite=Strict";break;case"lax":r+="; SameSite=Lax";break;case"strict":r+="; SameSite=Strict";break;case"none":r+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return r},l=function(e,o,t,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{path:"/",sameSite:"strict"};t&&(i.expires=new Date,i.expires.setTime(i.expires.getTime()+60*t*1e3)),n&&(i.domain=n),document.cookie=c(e,encodeURIComponent(o),i)},f=function(e){for(var o="".concat(e,"="),t=document.cookie.split(";"),n=0;n-1&&(t=window.location.hash.substring(window.location.hash.indexOf("?")));for(var n=t.substring(1).split("&"),i=0;i0)n[i].substring(0,r)===e.lookupQuerystring&&(o=n[i].substring(r+1))}}return o}},p=null,h=function(){if(null!==p)return p;try{p="undefined"!==window&&null!==window.localStorage;var e="i18next.translate.boo";window.localStorage.setItem(e,"foo"),window.localStorage.removeItem(e)}catch(e){p=!1}return p},m={name:"localStorage",lookup:function(e){var o;if(e.lookupLocalStorage&&h()){var t=window.localStorage.getItem(e.lookupLocalStorage);t&&(o=t)}return o},cacheUserLanguage:function(e,o){o.lookupLocalStorage&&h()&&window.localStorage.setItem(o.lookupLocalStorage,e)}},v=null,w=function(){if(null!==v)return v;try{v="undefined"!==window&&null!==window.sessionStorage;var e="i18next.translate.boo";window.sessionStorage.setItem(e,"foo"),window.sessionStorage.removeItem(e)}catch(e){v=!1}return v},y={name:"sessionStorage",lookup:function(e){var o;if(e.lookupSessionStorage&&w()){var t=window.sessionStorage.getItem(e.lookupSessionStorage);t&&(o=t)}return o},cacheUserLanguage:function(e,o){o.lookupSessionStorage&&w()&&window.sessionStorage.setItem(o.lookupSessionStorage,e)}},S={name:"navigator",lookup:function(e){var o=[];if("undefined"!=typeof navigator){if(navigator.languages)for(var t=0;t0?o:void 0}},k={name:"htmlTag",lookup:function(e){var o,t=e.htmlTag||("undefined"!=typeof document?document.documentElement:null);return t&&"function"==typeof t.getAttribute&&(o=t.getAttribute("lang")),o}},b={name:"path",lookup:function(e){var o;if("undefined"!=typeof window){var t=window.location.pathname.match(/\/([a-zA-Z-]*)/g);if(t instanceof Array)if("number"==typeof e.lookupFromPathIndex){if("string"!=typeof t[e.lookupFromPathIndex])return;o=t[e.lookupFromPathIndex].replace("/","")}else o=t[0].replace("/","")}return o}},x={name:"subdomain",lookup:function(e){var o="number"==typeof e.lookupFromSubdomainIndex?e.lookupFromSubdomainIndex+1:1,t="undefined"!=typeof window&&window.location&&window.location.hostname&&window.location.hostname.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(t)return t[o]}};var L=function(){function o(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e(this,o),this.type="languageDetector",this.detectors={},this.init(t,n)}var t,i,r;return t=o,i=[{key:"init",value:function(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.services=e||{languageUtils:{}},this.options=u(o,this.options||{},{order:["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"],lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:function(e){return e}}),"string"==typeof this.options.convertDetectedLanguage&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=function(e){return e.replace("-","_")}),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=t,this.addDetector(d),this.addDetector(g),this.addDetector(m),this.addDetector(y),this.addDetector(S),this.addDetector(k),this.addDetector(b),this.addDetector(x)}},{key:"addDetector",value:function(e){this.detectors[e.name]=e}},{key:"detect",value:function(e){var o=this;e||(e=this.options.order);var t=[];return e.forEach((function(e){if(o.detectors[e]){var n=o.detectors[e].lookup(o.options);n&&"string"==typeof n&&(n=[n]),n&&(t=t.concat(n))}})),t=t.map((function(e){return o.options.convertDetectedLanguage(e)})),this.services.languageUtils.getBestMatchFromCodes?t:t.length>0?t[0]:null}},{key:"cacheUserLanguage",value:function(e,o){var t=this;o||(o=this.options.caches),o&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(e)>-1||o.forEach((function(o){t.detectors[o]&&t.detectors[o].cacheUserLanguage(e,t.options)})))}}],i&&n(t.prototype,i),r&&n(t,r),Object.defineProperty(t,"prototype",{writable:!1}),o}();return L.type="languageDetector",L})); diff --git a/crates/ezidam/static/libs/i18next-http-backend/i18nextHttpBackend.min.js b/crates/ezidam/static/libs/i18next-http-backend/i18nextHttpBackend.min.js new file mode 100644 index 0000000..0e4aecf --- /dev/null +++ b/crates/ezidam/static/libs/i18next-http-backend/i18nextHttpBackend.min.js @@ -0,0 +1,2 @@ +// https://unpkg.com/i18next-http-backend@2.2.1/i18nextHttpBackend.min.js +!function(t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).i18nextHttpBackend=t()}(function(){return function o(i,r,a){function s(e,t){if(!r[e]){if(!i[e]){var n="function"==typeof require&&require;if(!t&&n)return n(e,!0);if(u)return u(e,!0);throw(t=new Error("Cannot find module '"+e+"'")).code="MODULE_NOT_FOUND",t}n=r[e]={exports:{}},i[e][0].call(n.exports,function(t){return s(i[e][1][t]||t)},n,n.exports,o,i,r,a)}return r[e].exports}for(var u="function"==typeof require&&require,t=0;t1&&void 0!==arguments[1]?arguments[1]:{};this.init(t,e)}init(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=s.prefix||"i18next:",this.logger=e||t,this.options=s,this.debug=s.debug}log(){for(var t=arguments.length,e=new Array(t),s=0;s{this.observers[t]=this.observers[t]||[],this.observers[t].push(e)})),this}off(t,e){this.observers[t]&&(e?this.observers[t]=this.observers[t].filter((t=>t!==e)):delete this.observers[t])}emit(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i{t(...s)}))}if(this.observers["*"]){[].concat(this.observers["*"]).forEach((e=>{e.apply(e,[t,...s])}))}}}function n(){let t,e;const s=new Promise(((s,i)=>{t=s,e=i}));return s.resolve=t,s.reject=e,s}function o(t){return null==t?"":""+t}function r(t,e,s){function i(t){return t&&t.indexOf("###")>-1?t.replace(/###/g,"."):t}function n(){return!t||"string"==typeof t}const o="string"!=typeof e?[].concat(e):e.split(".");for(;o.length>1;){if(n())return{};const e=i(o.shift());!t[e]&&s&&(t[e]=new s),t=Object.prototype.hasOwnProperty.call(t,e)?t[e]:{}}return n()?{}:{obj:t,k:i(o.shift())}}function a(t,e,s){const{obj:i,k:n}=r(t,e,Object);i[n]=s}function l(t,e){const{obj:s,k:i}=r(t,e);if(s)return s[i]}function u(t,e,s){for(const i in e)"__proto__"!==i&&"constructor"!==i&&(i in t?"string"==typeof t[i]||t[i]instanceof String||"string"==typeof e[i]||e[i]instanceof String?s&&(t[i]=e[i]):u(t[i],e[i],s):t[i]=e[i]);return t}function h(t){return t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var c={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function p(t){return"string"==typeof t?t.replace(/[&<>"'\/]/g,(t=>c[t])):t}const g=[" ",",","?","!",";"];function d(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(!t)return;if(t[e])return t[e];const i=e.split(s);let n=t;for(let t=0;tt+o;)o++,r=i.slice(t,t+o).join(s),a=n[r];if(void 0===a)return;if(null===a)return null;if(e.endsWith(r)){if("string"==typeof a)return a;if(r&&"string"==typeof a[r])return a[r]}const l=i.slice(t+o).join(s);return l?d(a,l,s):void 0}n=n[i[t]]}return n}function f(t){return t&&t.indexOf("_")>0?t.replace("_","-"):t}class m extends i{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=t||{},this.options=e,void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.indexOf(t)<0&&this.options.ns.push(t)}removeNamespaces(t){const e=this.options.ns.indexOf(t);e>-1&&this.options.ns.splice(e,1)}getResource(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const n=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator,o=void 0!==i.ignoreJSONStructure?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let r=[t,e];s&&"string"!=typeof s&&(r=r.concat(s)),s&&"string"==typeof s&&(r=r.concat(n?s.split(n):s)),t.indexOf(".")>-1&&(r=t.split("."));const a=l(this.data,r);return a||!o||"string"!=typeof s?a:d(this.data&&this.data[t]&&this.data[t][e],s,n)}addResource(t,e,s,i){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1};const o=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator;let r=[t,e];s&&(r=r.concat(o?s.split(o):s)),t.indexOf(".")>-1&&(r=t.split("."),i=e,e=r[1]),this.addNamespaces(e),a(this.data,r,i),n.silent||this.emit("added",t,e,s,i)}addResources(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(const i in s)"string"!=typeof s[i]&&"[object Array]"!==Object.prototype.toString.apply(s[i])||this.addResource(t,e,i,s[i],{silent:!0});i.silent||this.emit("added",t,e,s)}addResourceBundle(t,e,s,i,n){let o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},r=[t,e];t.indexOf(".")>-1&&(r=t.split("."),i=s,s=e,e=r[1]),this.addNamespaces(e);let h=l(this.data,r)||{};i?u(h,s,n):h={...h,...s},a(this.data,r,h),o.silent||this.emit("added",t,e,s)}removeResourceBundle(t,e){this.hasResourceBundle(t,e)&&delete this.data[t][e],this.removeNamespaces(e),this.emit("removed",t,e)}hasResourceBundle(t,e){return void 0!==this.getResource(t,e)}getResourceBundle(t,e){return e||(e=this.options.defaultNS),"v1"===this.options.compatibilityAPI?{...this.getResource(t,e)}:this.getResource(t,e)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){const e=this.getDataByLanguage(t);return!!(e&&Object.keys(e)||[]).find((t=>e[t]&&Object.keys(e[t]).length>0))}toJSON(){return this.data}}var y={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,s,i,n){return t.forEach((t=>{this.processors[t]&&(e=this.processors[t].process(e,s,i,n))})),e}};const v={};class b extends i{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var i,n;super(),i=t,n=this,["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"].forEach((t=>{i[t]&&(n[t]=i[t])})),this.options=e,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=s.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}};if(null==t)return!1;const s=this.resolve(t,e);return s&&void 0!==s.res}extractFromKey(t,e){let s=void 0!==e.nsSeparator?e.nsSeparator:this.options.nsSeparator;void 0===s&&(s=":");const i=void 0!==e.keySeparator?e.keySeparator:this.options.keySeparator;let n=e.ns||this.options.defaultNS||[];const o=s&&t.indexOf(s)>-1,r=!(this.options.userDefinedKeySeparator||e.keySeparator||this.options.userDefinedNsSeparator||e.nsSeparator||function(t,e,s){e=e||"",s=s||"";const i=g.filter((t=>e.indexOf(t)<0&&s.indexOf(t)<0));if(0===i.length)return!0;const n=new RegExp(`(${i.map((t=>"?"===t?"\\?":t)).join("|")})`);let o=!n.test(t);if(!o){const e=t.indexOf(s);e>0&&!n.test(t.substring(0,e))&&(o=!0)}return o}(t,s,i));if(o&&!r){const e=t.match(this.interpolator.nestingRegexp);if(e&&e.length>0)return{key:t,namespaces:n};const o=t.split(s);(s!==i||s===i&&this.options.ns.indexOf(o[0])>-1)&&(n=o.shift()),t=o.join(i)}return"string"==typeof n&&(n=[n]),{key:t,namespaces:n}}translate(t,e,s){if("object"!=typeof e&&this.options.overloadTranslationOptionHandler&&(e=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof e&&(e={...e}),e||(e={}),null==t)return"";Array.isArray(t)||(t=[String(t)]);const i=void 0!==e.returnDetails?e.returnDetails:this.options.returnDetails,n=void 0!==e.keySeparator?e.keySeparator:this.options.keySeparator,{key:o,namespaces:r}=this.extractFromKey(t[t.length-1],e),a=r[r.length-1],l=e.lng||this.language,u=e.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(l&&"cimode"===l.toLowerCase()){if(u){const t=e.nsSeparator||this.options.nsSeparator;return i?{res:`${a}${t}${o}`,usedKey:o,exactUsedKey:o,usedLng:l,usedNS:a}:`${a}${t}${o}`}return i?{res:o,usedKey:o,exactUsedKey:o,usedLng:l,usedNS:a}:o}const h=this.resolve(t,e);let c=h&&h.res;const p=h&&h.usedKey||o,g=h&&h.exactUsedKey||o,d=Object.prototype.toString.apply(c),f=void 0!==e.joinArrays?e.joinArrays:this.options.joinArrays,m=!this.i18nFormat||this.i18nFormat.handleAsObject;if(m&&c&&("string"!=typeof c&&"boolean"!=typeof c&&"number"!=typeof c)&&["[object Number]","[object Function]","[object RegExp]"].indexOf(d)<0&&("string"!=typeof f||"[object Array]"!==d)){if(!e.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const t=this.options.returnedObjectHandler?this.options.returnedObjectHandler(p,c,{...e,ns:r}):`key '${o} (${this.language})' returned an object instead of string.`;return i?(h.res=t,h):t}if(n){const t="[object Array]"===d,s=t?[]:{},i=t?g:p;for(const t in c)if(Object.prototype.hasOwnProperty.call(c,t)){const o=`${i}${n}${t}`;s[t]=this.translate(o,{...e,joinArrays:!1,ns:r}),s[t]===o&&(s[t]=c[t])}c=s}}else if(m&&"string"==typeof f&&"[object Array]"===d)c=c.join(f),c&&(c=this.extendTranslation(c,t,e,s));else{let i=!1,r=!1;const u=void 0!==e.count&&"string"!=typeof e.count,p=b.hasDefaultValue(e),g=u?this.pluralResolver.getSuffix(l,e.count,e):"",d=e.ordinal&&u?this.pluralResolver.getSuffix(l,e.count,{ordinal:!1}):"",f=e[`defaultValue${g}`]||e[`defaultValue${d}`]||e.defaultValue;!this.isValidLookup(c)&&p&&(i=!0,c=f),this.isValidLookup(c)||(r=!0,c=o);const m=(e.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&r?void 0:c,y=p&&f!==c&&this.options.updateMissing;if(r||i||y){if(this.logger.log(y?"updateKey":"missingKey",l,a,o,y?f:c),n){const t=this.resolve(o,{...e,keySeparator:!1});t&&t.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let t=[];const s=this.languageUtils.getFallbackCodes(this.options.fallbackLng,e.lng||this.language);if("fallback"===this.options.saveMissingTo&&s&&s[0])for(let e=0;e{const n=p&&i!==c?i:m;this.options.missingKeyHandler?this.options.missingKeyHandler(t,a,s,n,y,e):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(t,a,s,n,y,e),this.emit("missingKey",t,a,s,c)};this.options.saveMissing&&(this.options.saveMissingPlurals&&u?t.forEach((t=>{this.pluralResolver.getSuffixes(t,e).forEach((s=>{i([t],o+s,e[`defaultValue${s}`]||f)}))})):i(t,o,f))}c=this.extendTranslation(c,t,e,h,s),r&&c===o&&this.options.appendNamespaceToMissingKey&&(c=`${a}:${o}`),(r||i)&&this.options.parseMissingKeyHandler&&(c="v1"!==this.options.compatibilityAPI?this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${a}:${o}`:o,i?c:void 0):this.options.parseMissingKeyHandler(c))}return i?(h.res=c,h):c}extendTranslation(t,e,s,i,n){var o=this;if(this.i18nFormat&&this.i18nFormat.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...s},i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!s.skipInterpolation){s.interpolation&&this.interpolator.init({...s,interpolation:{...this.options.interpolation,...s.interpolation}});const r="string"==typeof t&&(s&&s.interpolation&&void 0!==s.interpolation.skipOnVariables?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let a;if(r){const e=t.match(this.interpolator.nestingRegexp);a=e&&e.length}let l=s.replace&&"string"!=typeof s.replace?s.replace:s;if(this.options.interpolation.defaultVariables&&(l={...this.options.interpolation.defaultVariables,...l}),t=this.interpolator.interpolate(t,l,s.lng||this.language,s),r){const e=t.match(this.interpolator.nestingRegexp);a<(e&&e.length)&&(s.nest=!1)}!s.lng&&"v1"!==this.options.compatibilityAPI&&i&&i.res&&(s.lng=i.usedLng),!1!==s.nest&&(t=this.interpolator.nest(t,(function(){for(var t=arguments.length,i=new Array(t),r=0;r1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof t&&(t=[t]),t.forEach((t=>{if(this.isValidLookup(e))return;const a=this.extractFromKey(t,r),l=a.key;s=l;let u=a.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));const h=void 0!==r.count&&"string"!=typeof r.count,c=h&&!r.ordinal&&0===r.count&&this.pluralResolver.shouldUseIntlApi(),p=void 0!==r.context&&("string"==typeof r.context||"number"==typeof r.context)&&""!==r.context,g=r.lngs?r.lngs:this.languageUtils.toResolveHierarchy(r.lng||this.language,r.fallbackLng);u.forEach((t=>{this.isValidLookup(e)||(o=t,!v[`${g[0]}-${t}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(o)&&(v[`${g[0]}-${t}`]=!0,this.logger.warn(`key "${s}" for languages "${g.join(", ")}" won't get resolved as namespace "${o}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),g.forEach((s=>{if(this.isValidLookup(e))return;n=s;const o=[l];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(o,l,s,t,r);else{let t;h&&(t=this.pluralResolver.getSuffix(s,r.count,r));const e=`${this.options.pluralSeparator}zero`,i=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(h&&(o.push(l+t),r.ordinal&&0===t.indexOf(i)&&o.push(l+t.replace(i,this.options.pluralSeparator)),c&&o.push(l+e)),p){const s=`${l}${this.options.contextSeparator}${r.context}`;o.push(s),h&&(o.push(s+t),r.ordinal&&0===t.indexOf(i)&&o.push(s+t.replace(i,this.options.pluralSeparator)),c&&o.push(s+e))}}let a;for(;a=o.pop();)this.isValidLookup(e)||(i=a,e=this.getResource(s,t,a,r))})))}))})),{res:e,usedKey:s,exactUsedKey:i,usedLng:n,usedNS:o}}isValidLookup(t){return!(void 0===t||!this.options.returnNull&&null===t||!this.options.returnEmptyString&&""===t)}getResource(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(t,e,s,i):this.resourceStore.getResource(t,e,s,i)}static hasDefaultValue(t){const e="defaultValue";for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)&&e===s.substring(0,12)&&void 0!==t[s])return!0;return!1}}function x(t){return t.charAt(0).toUpperCase()+t.slice(1)}class S{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=s.create("languageUtils")}getScriptPartFromCode(t){if(!(t=f(t))||t.indexOf("-")<0)return null;const e=t.split("-");return 2===e.length?null:(e.pop(),"x"===e[e.length-1].toLowerCase()?null:this.formatLanguageCode(e.join("-")))}getLanguagePartFromCode(t){if(!(t=f(t))||t.indexOf("-")<0)return t;const e=t.split("-");return this.formatLanguageCode(e[0])}formatLanguageCode(t){if("string"==typeof t&&t.indexOf("-")>-1){const e=["hans","hant","latn","cyrl","cans","mong","arab"];let s=t.split("-");return this.options.lowerCaseLng?s=s.map((t=>t.toLowerCase())):2===s.length?(s[0]=s[0].toLowerCase(),s[1]=s[1].toUpperCase(),e.indexOf(s[1].toLowerCase())>-1&&(s[1]=x(s[1].toLowerCase()))):3===s.length&&(s[0]=s[0].toLowerCase(),2===s[1].length&&(s[1]=s[1].toUpperCase()),"sgn"!==s[0]&&2===s[2].length&&(s[2]=s[2].toUpperCase()),e.indexOf(s[1].toLowerCase())>-1&&(s[1]=x(s[1].toLowerCase())),e.indexOf(s[2].toLowerCase())>-1&&(s[2]=x(s[2].toLowerCase()))),s.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}getBestMatchFromCodes(t){if(!t)return null;let e;return t.forEach((t=>{if(e)return;const s=this.formatLanguageCode(t);this.options.supportedLngs&&!this.isSupportedCode(s)||(e=s)})),!e&&this.options.supportedLngs&&t.forEach((t=>{if(e)return;const s=this.getLanguagePartFromCode(t);if(this.isSupportedCode(s))return e=s;e=this.options.supportedLngs.find((t=>t===s?t:t.indexOf("-")<0&&s.indexOf("-")<0?void 0:0===t.indexOf(s)?t:void 0))})),e||(e=this.getFallbackCodes(this.options.fallbackLng)[0]),e}getFallbackCodes(t,e){if(!t)return[];if("function"==typeof t&&(t=t(e)),"string"==typeof t&&(t=[t]),"[object Array]"===Object.prototype.toString.apply(t))return t;if(!e)return t.default||[];let s=t[e];return s||(s=t[this.getScriptPartFromCode(e)]),s||(s=t[this.formatLanguageCode(e)]),s||(s=t[this.getLanguagePartFromCode(e)]),s||(s=t.default),s||[]}toResolveHierarchy(t,e){const s=this.getFallbackCodes(e||this.options.fallbackLng||[],t),i=[],n=t=>{t&&(this.isSupportedCode(t)?i.push(t):this.logger.warn(`rejecting language code not found in supportedLngs: ${t}`))};return"string"==typeof t&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?("languageOnly"!==this.options.load&&n(this.formatLanguageCode(t)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&n(this.getScriptPartFromCode(t)),"currentOnly"!==this.options.load&&n(this.getLanguagePartFromCode(t))):"string"==typeof t&&n(this.formatLanguageCode(t)),s.forEach((t=>{i.indexOf(t)<0&&n(this.formatLanguageCode(t))})),i}}let k=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],L={1:function(t){return Number(t>1)},2:function(t){return Number(1!=t)},3:function(t){return 0},4:function(t){return Number(t%10==1&&t%100!=11?0:t%10>=2&&t%10<=4&&(t%100<10||t%100>=20)?1:2)},5:function(t){return Number(0==t?0:1==t?1:2==t?2:t%100>=3&&t%100<=10?3:t%100>=11?4:5)},6:function(t){return Number(1==t?0:t>=2&&t<=4?1:2)},7:function(t){return Number(1==t?0:t%10>=2&&t%10<=4&&(t%100<10||t%100>=20)?1:2)},8:function(t){return Number(1==t?0:2==t?1:8!=t&&11!=t?2:3)},9:function(t){return Number(t>=2)},10:function(t){return Number(1==t?0:2==t?1:t<7?2:t<11?3:4)},11:function(t){return Number(1==t||11==t?0:2==t||12==t?1:t>2&&t<20?2:3)},12:function(t){return Number(t%10!=1||t%100==11)},13:function(t){return Number(0!==t)},14:function(t){return Number(1==t?0:2==t?1:3==t?2:3)},15:function(t){return Number(t%10==1&&t%100!=11?0:t%10>=2&&(t%100<10||t%100>=20)?1:2)},16:function(t){return Number(t%10==1&&t%100!=11?0:0!==t?1:2)},17:function(t){return Number(1==t||t%10==1&&t%100!=11?0:1)},18:function(t){return Number(0==t?0:1==t?1:2)},19:function(t){return Number(1==t?0:0==t||t%100>1&&t%100<11?1:t%100>10&&t%100<20?2:3)},20:function(t){return Number(1==t?0:0==t||t%100>0&&t%100<20?1:2)},21:function(t){return Number(t%100==1?1:t%100==2?2:t%100==3||t%100==4?3:0)},22:function(t){return Number(1==t?0:2==t?1:(t<0||t>10)&&t%10==0?2:3)}};const O=["v1","v2","v3"],w=["v4"],N={zero:0,one:1,two:2,few:3,many:4,other:5};class R{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.languageUtils=t,this.options=e,this.logger=s.create("pluralResolver"),this.options.compatibilityJSON&&!w.includes(this.options.compatibilityJSON)||"undefined"!=typeof Intl&&Intl.PluralRules||(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=function(){const t={};return k.forEach((e=>{e.lngs.forEach((s=>{t[s]={numbers:e.nr,plurals:L[e.fc]}}))})),t}()}addRule(t,e){this.rules[t]=e}getRule(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(f(t),{type:e.ordinal?"ordinal":"cardinal"})}catch{return}return this.rules[t]||this.rules[this.languageUtils.getLanguagePartFromCode(t)]}needsPlural(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=this.getRule(t,e);return this.shouldUseIntlApi()?s&&s.resolvedOptions().pluralCategories.length>1:s&&s.numbers.length>1}getPluralFormsOfKey(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.getSuffixes(t,s).map((t=>`${e}${t}`))}getSuffixes(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=this.getRule(t,e);return s?this.shouldUseIntlApi()?s.resolvedOptions().pluralCategories.sort(((t,e)=>N[t]-N[e])).map((t=>`${this.options.prepend}${e.ordinal?`ordinal${this.options.prepend}`:""}${t}`)):s.numbers.map((s=>this.getSuffix(t,s,e))):[]}getSuffix(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=this.getRule(t,s);return i?this.shouldUseIntlApi()?`${this.options.prepend}${s.ordinal?`ordinal${this.options.prepend}`:""}${i.select(e)}`:this.getSuffixRetroCompatible(i,e):(this.logger.warn(`no plural rule found for: ${t}`),"")}getSuffixRetroCompatible(t,e){const s=t.noAbs?t.plurals(e):t.plurals(Math.abs(e));let i=t.numbers[s];this.options.simplifyPluralSuffix&&2===t.numbers.length&&1===t.numbers[0]&&(2===i?i="plural":1===i&&(i=""));const n=()=>this.options.prepend&&i.toString()?this.options.prepend+i.toString():i.toString();return"v1"===this.options.compatibilityJSON?1===i?"":"number"==typeof i?`_plural_${i.toString()}`:n():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===t.numbers.length&&1===t.numbers[0]?n():this.options.prepend&&s.toString()?this.options.prepend+s.toString():s.toString()}shouldUseIntlApi(){return!O.includes(this.options.compatibilityJSON)}}function $(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:".",n=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=function(t,e,s){const i=l(t,s);return void 0!==i?i:l(e,s)}(t,e,s);return!o&&n&&"string"==typeof s&&(o=d(t,s,i),void 0===o&&(o=d(e,s,i))),o}class C{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.logger=s.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||(t=>t),this.init(t)}init(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t.interpolation||(t.interpolation={escapeValue:!0});const e=t.interpolation;this.escape=void 0!==e.escape?e.escape:p,this.escapeValue=void 0===e.escapeValue||e.escapeValue,this.useRawValueToEscape=void 0!==e.useRawValueToEscape&&e.useRawValueToEscape,this.prefix=e.prefix?h(e.prefix):e.prefixEscaped||"{{",this.suffix=e.suffix?h(e.suffix):e.suffixEscaped||"}}",this.formatSeparator=e.formatSeparator?e.formatSeparator:e.formatSeparator||",",this.unescapePrefix=e.unescapeSuffix?"":e.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":e.unescapeSuffix||"",this.nestingPrefix=e.nestingPrefix?h(e.nestingPrefix):e.nestingPrefixEscaped||h("$t("),this.nestingSuffix=e.nestingSuffix?h(e.nestingSuffix):e.nestingSuffixEscaped||h(")"),this.nestingOptionsSeparator=e.nestingOptionsSeparator?e.nestingOptionsSeparator:e.nestingOptionsSeparator||",",this.maxReplaces=e.maxReplaces?e.maxReplaces:1e3,this.alwaysFormat=void 0!==e.alwaysFormat&&e.alwaysFormat,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=`${this.prefix}(.+?)${this.suffix}`;this.regexp=new RegExp(t,"g");const e=`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`;this.regexpUnescape=new RegExp(e,"g");const s=`${this.nestingPrefix}(.+?)${this.nestingSuffix}`;this.nestingRegexp=new RegExp(s,"g")}interpolate(t,e,s,i){let n,r,a;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function u(t){return t.replace(/\$/g,"$$$$")}const h=t=>{if(t.indexOf(this.formatSeparator)<0){const n=$(e,l,t,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(n,void 0,s,{...i,...e,interpolationkey:t}):n}const n=t.split(this.formatSeparator),o=n.shift().trim(),r=n.join(this.formatSeparator).trim();return this.format($(e,l,o,this.options.keySeparator,this.options.ignoreJSONStructure),r,s,{...i,...e,interpolationkey:o})};this.resetRegExp();const c=i&&i.missingInterpolationHandler||this.options.missingInterpolationHandler,p=i&&i.interpolation&&void 0!==i.interpolation.skipOnVariables?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:t=>u(t)},{regex:this.regexp,safeValue:t=>this.escapeValue?u(this.escape(t)):u(t)}].forEach((e=>{for(a=0;n=e.regex.exec(t);){const s=n[1].trim();if(r=h(s),void 0===r)if("function"==typeof c){const e=c(t,n,i);r="string"==typeof e?e:""}else if(i&&Object.prototype.hasOwnProperty.call(i,s))r="";else{if(p){r=n[0];continue}this.logger.warn(`missed to pass in variable ${s} for interpolating ${t}`),r=""}else"string"==typeof r||this.useRawValueToEscape||(r=o(r));const l=e.safeValue(r);if(t=t.replace(n[0],l),p?(e.regex.lastIndex+=r.length,e.regex.lastIndex-=n[0].length):e.regex.lastIndex=0,a++,a>=this.maxReplaces)break}})),t}nest(t,e){let s,i,n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};function a(t,e){const s=this.nestingOptionsSeparator;if(t.indexOf(s)<0)return t;const i=t.split(new RegExp(`${s}[ ]*{`));let o=`{${i[1]}`;t=i[0],o=this.interpolate(o,n);const r=o.match(/'/g),a=o.match(/"/g);(r&&r.length%2==0&&!a||a.length%2!=0)&&(o=o.replace(/'/g,'"'));try{n=JSON.parse(o),e&&(n={...e,...n})}catch(e){return this.logger.warn(`failed parsing options string in nesting for key ${t}`,e),`${t}${s}${o}`}return delete n.defaultValue,t}for(;s=this.nestingRegexp.exec(t);){let l=[];n={...r},n=n.replace&&"string"!=typeof n.replace?n.replace:n,n.applyPostProcessor=!1,delete n.defaultValue;let u=!1;if(-1!==s[0].indexOf(this.formatSeparator)&&!/{.*}/.test(s[1])){const t=s[1].split(this.formatSeparator).map((t=>t.trim()));s[1]=t.shift(),l=t,u=!0}if(i=e(a.call(this,s[1].trim(),n),n),i&&s[0]===t&&"string"!=typeof i)return i;"string"!=typeof i&&(i=o(i)),i||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),i=""),u&&(i=l.reduce(((t,e)=>this.format(t,e,r.lng,{...r,interpolationkey:s[1].trim()})),i.trim())),t=t.replace(s[0],i),this.regexp.lastIndex=0}return t}}function P(t){const e={};return function(s,i,n){const o=i+JSON.stringify(n);let r=e[o];return r||(r=t(f(i),n),e[o]=r),r(s)}}class j{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.logger=s.create("formatter"),this.options=t,this.formats={number:P(((t,e)=>{const s=new Intl.NumberFormat(t,{...e});return t=>s.format(t)})),currency:P(((t,e)=>{const s=new Intl.NumberFormat(t,{...e,style:"currency"});return t=>s.format(t)})),datetime:P(((t,e)=>{const s=new Intl.DateTimeFormat(t,{...e});return t=>s.format(t)})),relativetime:P(((t,e)=>{const s=new Intl.RelativeTimeFormat(t,{...e});return t=>s.format(t,e.range||"day")})),list:P(((t,e)=>{const s=new Intl.ListFormat(t,{...e});return t=>s.format(t)}))},this.init(t)}init(t){const e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}}).interpolation;this.formatSeparator=e.formatSeparator?e.formatSeparator:e.formatSeparator||","}add(t,e){this.formats[t.toLowerCase().trim()]=e}addCached(t,e){this.formats[t.toLowerCase().trim()]=P(e)}format(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return e.split(this.formatSeparator).reduce(((t,e)=>{const{formatName:n,formatOptions:o}=function(t){let e=t.toLowerCase().trim();const s={};if(t.indexOf("(")>-1){const i=t.split("(");e=i[0].toLowerCase().trim();const n=i[1].substring(0,i[1].length-1);"currency"===e&&n.indexOf(":")<0?s.currency||(s.currency=n.trim()):"relativetime"===e&&n.indexOf(":")<0?s.range||(s.range=n.trim()):n.split(";").forEach((t=>{if(!t)return;const[e,...i]=t.split(":"),n=i.join(":").trim().replace(/^'+|'+$/g,"");s[e.trim()]||(s[e.trim()]=n),"false"===n&&(s[e.trim()]=!1),"true"===n&&(s[e.trim()]=!0),isNaN(n)||(s[e.trim()]=parseInt(n,10))}))}return{formatName:e,formatOptions:s}}(e);if(this.formats[n]){let e=t;try{const r=i&&i.formatParams&&i.formatParams[i.interpolationkey]||{},a=r.locale||r.lng||i.locale||i.lng||s;e=this.formats[n](t,a,{...o,...i,...r})}catch(t){this.logger.warn(t)}return e}return this.logger.warn(`there was no format function for ${n}`),t}),t)}}class E extends i{constructor(t,e,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};super(),this.backend=t,this.store=e,this.services=i,this.languageUtils=i.languageUtils,this.options=n,this.logger=s.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=n.maxParallelReads||10,this.readingCalls=0,this.maxRetries=n.maxRetries>=0?n.maxRetries:5,this.retryTimeout=n.retryTimeout>=1?n.retryTimeout:350,this.state={},this.queue=[],this.backend&&this.backend.init&&this.backend.init(i,n.backend,n)}queueLoad(t,e,s,i){const n={},o={},r={},a={};return t.forEach((t=>{let i=!0;e.forEach((e=>{const r=`${t}|${e}`;!s.reload&&this.store.hasResourceBundle(t,e)?this.state[r]=2:this.state[r]<0||(1===this.state[r]?void 0===o[r]&&(o[r]=!0):(this.state[r]=1,i=!1,void 0===o[r]&&(o[r]=!0),void 0===n[r]&&(n[r]=!0),void 0===a[e]&&(a[e]=!0)))})),i||(r[t]=!0)})),(Object.keys(n).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(n),pending:Object.keys(o),toLoadLanguages:Object.keys(r),toLoadNamespaces:Object.keys(a)}}loaded(t,e,s){const i=t.split("|"),n=i[0],o=i[1];e&&this.emit("failedLoading",n,o,e),s&&this.store.addResourceBundle(n,o,s),this.state[t]=e?-1:2;const a={};this.queue.forEach((s=>{!function(t,e,s,i){const{obj:n,k:o}=r(t,e,Object);n[o]=n[o]||[],i&&(n[o]=n[o].concat(s)),i||n[o].push(s)}(s.loaded,[n],o),function(t,e){void 0!==t.pending[e]&&(delete t.pending[e],t.pendingCount--)}(s,t),e&&s.errors.push(e),0!==s.pendingCount||s.done||(Object.keys(s.loaded).forEach((t=>{a[t]||(a[t]={});const e=s.loaded[t];e.length&&e.forEach((e=>{void 0===a[t][e]&&(a[t][e]=!0)}))})),s.done=!0,s.errors.length?s.callback(s.errors):s.callback())})),this.emit("loaded",a),this.queue=this.queue.filter((t=>!t.done))}read(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.retryTimeout,o=arguments.length>5?arguments[5]:void 0;if(!t.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:t,ns:e,fcName:s,tried:i,wait:n,callback:o});this.readingCalls++;const r=(r,a)=>{if(this.readingCalls--,this.waitingReads.length>0){const t=this.waitingReads.shift();this.read(t.lng,t.ns,t.fcName,t.tried,t.wait,t.callback)}r&&a&&i{this.read.call(this,t,e,s,i+1,2*n,o)}),n):o(r,a)},a=this.backend[s].bind(this.backend);if(2!==a.length)return a(t,e,r);try{const s=a(t,e);s&&"function"==typeof s.then?s.then((t=>r(null,t))).catch(r):r(null,s)}catch(t){r(t)}}prepareLoading(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();"string"==typeof t&&(t=this.languageUtils.toResolveHierarchy(t)),"string"==typeof e&&(e=[e]);const n=this.queueLoad(t,e,s,i);if(!n.toLoad.length)return n.pending.length||i(),null;n.toLoad.forEach((t=>{this.loadOne(t)}))}load(t,e,s){this.prepareLoading(t,e,{},s)}reload(t,e,s){this.prepareLoading(t,e,{reload:!0},s)}loadOne(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const s=t.split("|"),i=s[0],n=s[1];this.read(i,n,"read",void 0,void 0,((s,o)=>{s&&this.logger.warn(`${e}loading namespace ${n} for language ${i} failed`,s),!s&&o&&this.logger.log(`${e}loaded namespace ${n} for language ${i}`,o),this.loaded(t,s,o)}))}saveMissing(t,e,s,i,n){let o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:()=>{};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(e))this.logger.warn(`did not save key "${s}" as the namespace "${e}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");else if(null!=s&&""!==s){if(this.backend&&this.backend.create){const a={...o,isUpdate:n},l=this.backend.create.bind(this.backend);if(l.length<6)try{let n;n=5===l.length?l(t,e,s,i,a):l(t,e,s,i),n&&"function"==typeof n.then?n.then((t=>r(null,t))).catch(r):r(null,n)}catch(t){r(t)}else l(t,e,s,i,r,a)}t&&t[0]&&this.store.addResource(t[0],e,s,i)}}}function F(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(t){let e={};if("object"==typeof t[1]&&(e=t[1]),"string"==typeof t[1]&&(e.defaultValue=t[1]),"string"==typeof t[2]&&(e.tDescription=t[2]),"object"==typeof t[2]||"object"==typeof t[3]){const s=t[3]||t[2];Object.keys(s).forEach((t=>{e[t]=s[t]}))}return e},interpolation:{escapeValue:!0,format:(t,e,s,i)=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function I(t){return"string"==typeof t.ns&&(t.ns=[t.ns]),"string"==typeof t.fallbackLng&&(t.fallbackLng=[t.fallbackLng]),"string"==typeof t.fallbackNS&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs&&t.supportedLngs.indexOf("cimode")<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),t}function T(){}class V extends i{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;var i;if(super(),this.options=I(t),this.services={},this.logger=s,this.modules={external:[]},i=this,Object.getOwnPropertyNames(Object.getPrototypeOf(i)).forEach((t=>{"function"==typeof i[t]&&(i[t]=i[t].bind(i))})),e&&!this.isInitialized&&!t.isClone){if(!this.options.initImmediate)return this.init(t,e),this;setTimeout((()=>{this.init(t,e)}),0)}}init(){var t=this;let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;"function"==typeof e&&(i=e,e={}),!e.defaultNS&&!1!==e.defaultNS&&e.ns&&("string"==typeof e.ns?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const o=F();function r(t){return t?"function"==typeof t?new t:t:null}if(this.options={...o,...this.options,...I(e)},"v1"!==this.options.compatibilityAPI&&(this.options.interpolation={...o.interpolation,...this.options.interpolation}),void 0!==e.keySeparator&&(this.options.userDefinedKeySeparator=e.keySeparator),void 0!==e.nsSeparator&&(this.options.userDefinedNsSeparator=e.nsSeparator),!this.options.isClone){let e;this.modules.logger?s.init(r(this.modules.logger),this.options):s.init(null,this.options),this.modules.formatter?e=this.modules.formatter:"undefined"!=typeof Intl&&(e=j);const i=new S(this.options);this.store=new m(this.options.resources,this.options);const n=this.services;n.logger=s,n.resourceStore=this.store,n.languageUtils=i,n.pluralResolver=new R(i,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),!e||this.options.interpolation.format&&this.options.interpolation.format!==o.interpolation.format||(n.formatter=r(e),n.formatter.init(n,this.options),this.options.interpolation.format=n.formatter.format.bind(n.formatter)),n.interpolator=new C(this.options),n.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},n.backendConnector=new E(r(this.modules.backend),n.resourceStore,n,this.options),n.backendConnector.on("*",(function(e){for(var s=arguments.length,i=new Array(s>1?s-1:0),n=1;n1?s-1:0),n=1;n{t.init&&t.init(this)}))}if(this.format=this.options.interpolation.format,i||(i=T),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const t=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);t.length>0&&"dev"!==t[0]&&(this.options.lng=t[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined");["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach((e=>{this[e]=function(){return t.store[e](...arguments)}}));["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach((e=>{this[e]=function(){return t.store[e](...arguments),t}}));const a=n(),l=()=>{const t=(t,e)=>{this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),a.resolve(e),i(t,e)};if(this.languages&&"v1"!==this.options.compatibilityAPI&&!this.isInitialized)return t(null,this.t.bind(this));this.changeLanguage(this.options.lng,t)};return this.options.resources||!this.options.initImmediate?l():setTimeout(l,0),a}loadResources(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:T;const s="string"==typeof t?t:this.language;if("function"==typeof t&&(e=t),!this.options.resources||this.options.partialBundledLanguages){if(s&&"cimode"===s.toLowerCase())return e();const t=[],i=e=>{if(!e)return;this.services.languageUtils.toResolveHierarchy(e).forEach((e=>{t.indexOf(e)<0&&t.push(e)}))};if(s)i(s);else{this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((t=>i(t)))}this.options.preload&&this.options.preload.forEach((t=>i(t))),this.services.backendConnector.load(t,this.options.ns,(t=>{t||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),e(t)}))}else e(null)}reloadResources(t,e,s){const i=n();return t||(t=this.languages),e||(e=this.options.ns),s||(s=T),this.services.backendConnector.reload(t,e,(t=>{i.resolve(),s(t)})),i}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===t.type&&(this.modules.backend=t),("logger"===t.type||t.log&&t.warn&&t.error)&&(this.modules.logger=t),"languageDetector"===t.type&&(this.modules.languageDetector=t),"i18nFormat"===t.type&&(this.modules.i18nFormat=t),"postProcessor"===t.type&&y.addPostProcessor(t),"formatter"===t.type&&(this.modules.formatter=t),"3rdParty"===t.type&&this.modules.external.push(t),this}setResolvedLanguage(t){if(t&&this.languages&&!(["cimode","dev"].indexOf(t)>-1))for(let t=0;t-1)&&this.store.hasLanguageSomeTranslations(e)){this.resolvedLanguage=e;break}}}changeLanguage(t,e){var s=this;this.isLanguageChangingTo=t;const i=n();this.emit("languageChanging",t);const o=t=>{this.language=t,this.languages=this.services.languageUtils.toResolveHierarchy(t),this.resolvedLanguage=void 0,this.setResolvedLanguage(t)},r=(t,n)=>{n?(o(n),this.translator.changeLanguage(n),this.isLanguageChangingTo=void 0,this.emit("languageChanged",n),this.logger.log("languageChanged",n)):this.isLanguageChangingTo=void 0,i.resolve((function(){return s.t(...arguments)})),e&&e(t,(function(){return s.t(...arguments)}))},a=e=>{t||e||!this.services.languageDetector||(e=[]);const s="string"==typeof e?e:this.services.languageUtils.getBestMatchFromCodes(e);s&&(this.language||o(s),this.translator.language||this.translator.changeLanguage(s),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(s)),this.loadResources(s,(t=>{r(t,s)}))};return t||!this.services.languageDetector||this.services.languageDetector.async?!t&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(t):a(this.services.languageDetector.detect()),i}getFixedT(t,e,s){var i=this;const n=function(t,e){let o;if("object"!=typeof e){for(var r=arguments.length,a=new Array(r>2?r-2:0),l=2;l`${o.keyPrefix}${u}${t}`)):o.keyPrefix?`${o.keyPrefix}${u}${t}`:t,i.t(h,o)};return"string"==typeof t?n.lng=t:n.lngs=t,n.ns=e,n.keyPrefix=s,n}t(){return this.translator&&this.translator.translate(...arguments)}exists(){return this.translator&&this.translator.exists(...arguments)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const s=e.lng||this.resolvedLanguage||this.languages[0],i=!!this.options&&this.options.fallbackLng,n=this.languages[this.languages.length-1];if("cimode"===s.toLowerCase())return!0;const o=(t,e)=>{const s=this.services.backendConnector.state[`${t}|${e}`];return-1===s||2===s};if(e.precheck){const t=e.precheck(this,o);if(void 0!==t)return t}return!!this.hasResourceBundle(s,t)||(!(this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages))||!(!o(s,t)||i&&!o(n,t)))}loadNamespaces(t,e){const s=n();return this.options.ns?("string"==typeof t&&(t=[t]),t.forEach((t=>{this.options.ns.indexOf(t)<0&&this.options.ns.push(t)})),this.loadResources((t=>{s.resolve(),e&&e(t)})),s):(e&&e(),Promise.resolve())}loadLanguages(t,e){const s=n();"string"==typeof t&&(t=[t]);const i=this.options.preload||[],o=t.filter((t=>i.indexOf(t)<0));return o.length?(this.options.preload=i.concat(o),this.loadResources((t=>{s.resolve(),e&&e(t)})),s):(e&&e(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!t)return"rtl";const e=this.services&&this.services.languageUtils||new S(F());return["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(e.getLanguagePartFromCode(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(){return new V(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},arguments.length>1?arguments[1]:void 0)}cloneInstance(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:T;const s=t.forkResourceStore;s&&delete t.forkResourceStore;const i={...this.options,...t,isClone:!0},n=new V(i);void 0===t.debug&&void 0===t.prefix||(n.logger=n.logger.clone(t));return["store","services","language"].forEach((t=>{n[t]=this[t]})),n.services={...this.services},n.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},s&&(n.store=new m(this.store.data,i),n.services.resourceStore=n.store),n.translator=new b(n.services,i),n.translator.on("*",(function(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i"),u=t.innerHTML.indexOf("")+11;l>-1&&u>6&&(t.innerHTML=[t.innerHTML.substring(0,l),t.innerHTML.slice(u)].join("")),t.innerHTML=["",e.t(n,c(r,t.innerHTML)),"",t.innerHTML].join("")}else if("append"===i){var f=t.innerHTML.indexOf(""),s=t.innerHTML.indexOf("")+11;f>-1&&s>6&&(t.innerHTML=[t.innerHTML.substring(0,f),t.innerHTML.slice(s)].join("")),t.innerHTML=[t.innerHTML,"",e.t(n,c(r,t.innerHTML),"")].join("")}else if(0===i.indexOf("data-")){var a=i.substr("data-".length),p=e.t(n,c(r,t.getAttribute(a)));t.setAttribute(a,p),t.setAttribute(i,p)}else t.setAttribute(i,e.t(n,c(r,t.getAttribute(i))))}function i(e){return JSON.parse(e.replace(/:\s*"([^"]*)"/g,function(e,t){return': "'+t.replace(/:/g,"@colon@")+'"'}).replace(/:\s*'([^']*)'/g,function(e,t){return': "'+t.replace(/:/g,"@colon@")+'"'}).replace(/(['"])?([a-z0-9A-Z_]+)(['"])?\s*:/g,'"$2": ').replace(/@colon@/g,":"))}function o(e,r){var o=e.getAttribute(u.selectorAttr);if(o){var l=e,c=e.getAttribute(u.targetAttr);if(null!=c&&(l=e.querySelector(c)||e),r||!0!==u.useOptionsAttr||(r=i(e.getAttribute(u.optionsAttr)||"{}")),r=r||{},o.indexOf(";")>=0)for(var f=o.split(";"),s=0,a=f.length;s-1;f--)o(c[f],t);o(l,t)}}var u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};u=t({},r,u);var c=function(e,n){return u.parseDefaultValueFromContent?t({},e,{defaultValue:n}):e};return l}var r={selectorAttr:"data-i18n",targetAttr:"i18n-target",optionsAttr:"i18n-options",useOptionsAttr:!1,parseDefaultValueFromContent:!0,document:document};return{init:n}}); \ No newline at end of file diff --git a/crates/ezidam/templates/base.html.tera b/crates/ezidam/templates/base.html.tera index 66bca97..f8a999b 100644 --- a/crates/ezidam/templates/base.html.tera +++ b/crates/ezidam/templates/base.html.tera @@ -1,5 +1,5 @@ - + @@ -9,6 +9,11 @@ + + + + + @@ -27,5 +32,34 @@ } + {% block page %}{% endblock page %} + + \ No newline at end of file diff --git a/crates/ezidam/templates/shell.html.tera b/crates/ezidam/templates/shell.html.tera index a271e30..41c887b 100644 --- a/crates/ezidam/templates/shell.html.tera +++ b/crates/ezidam/templates/shell.html.tera @@ -21,3 +21,7 @@ {% block additional_js %}{% endblock additional_js %} {% endblock page %} + +{% block i18n %} +localize("#header_user_nav"); +{% endblock i18n %} diff --git a/crates/ezidam/templates/shell/header.html.tera b/crates/ezidam/templates/shell/header.html.tera index 3cc511e..6c0aadc 100644 --- a/crates/ezidam/templates/shell/header.html.tera +++ b/crates/ezidam/templates/shell/header.html.tera @@ -16,7 +16,7 @@ {{ user::user_info(name=user.name, username=user.username, email=user.email) }} - {% endif %} -
-

Reset your password

+
+

-

- Enter your email address linked to your account. We will email you a link to reset your - password. -

+

- - + +
-

- Enter your login linked to your account, with your paper key. -

+

- - + +
- - + +
@@ -94,3 +83,7 @@ {% endblock page %} + +{% block i18n %} +localize("#forgot_password_card"); +{% endblock i18n %} diff --git a/crates/ezidam/templates/pages/setup.html.tera b/crates/ezidam/templates/pages/setup.html.tera index eee269c..d967fae 100644 --- a/crates/ezidam/templates/pages/setup.html.tera +++ b/crates/ezidam/templates/pages/setup.html.tera @@ -15,35 +15,33 @@
{% endif %} -
+
-

Welcome to Ezidam!

-

Initial setup

+

+

-
first admin account
+
- - + +
- +
- +
-
settings
+
- +
@@ -52,7 +50,7 @@
- +
@@ -66,3 +64,7 @@ {% endblock page %} + +{% block i18n %} +localize("#setup_form"); +{% endblock i18n %} From 9a7bd1b47636981686b2e4969a0d6e3a7cb07291 Mon Sep 17 00:00:00 2001 From: Philippe Loctaux Date: Sun, 6 Aug 2023 23:29:01 +0200 Subject: [PATCH 03/11] translated reset-password --- crates/ezidam/src/routes/root.rs | 4 +--- .../ezidam/src/routes/root/reset_password.rs | 6 ++---- crates/ezidam/static/i18n/en.json | 8 ++++++-- crates/ezidam/static/i18n/fr.json | 8 ++++++-- .../templates/pages/reset-password.html.tera | 20 ++++++++++--------- 5 files changed, 26 insertions(+), 20 deletions(-) diff --git a/crates/ezidam/src/routes/root.rs b/crates/ezidam/src/routes/root.rs index a2bc456..a538b07 100644 --- a/crates/ezidam/src/routes/root.rs +++ b/crates/ezidam/src/routes/root.rs @@ -41,7 +41,5 @@ pub mod content { #[derive(Serialize)] #[serde(crate = "rocket::serde")] #[derive(Clone)] - pub struct ResetPassword { - pub username: String, - } + pub struct ResetPassword {} } diff --git a/crates/ezidam/src/routes/root/reset_password.rs b/crates/ezidam/src/routes/root/reset_password.rs index 6b15765..41367cb 100644 --- a/crates/ezidam/src/routes/root/reset_password.rs +++ b/crates/ezidam/src/routes/root/reset_password.rs @@ -12,13 +12,11 @@ pub async fn reset_password_page( return Err(Error::bad_request("Reset password token has expired")); } - let user = User::get_one_from_password_reset_token(&mut **db, &token.0) + User::get_one_from_password_reset_token(&mut **db, &token.0) .await? .ok_or_else(|| Error::not_found("Invalid or expired token"))?; - let page = Page::ResetPassword(super::content::ResetPassword { - username: user.username().into(), - }); + let page = Page::ResetPassword(super::content::ResetPassword {}); Ok(flash .map(|flash| Page::with_flash(page.clone(), flash)) diff --git a/crates/ezidam/static/i18n/en.json b/crates/ezidam/static/i18n/en.json index f20d51b..2292c28 100644 --- a/crates/ezidam/static/i18n/en.json +++ b/crates/ezidam/static/i18n/en.json @@ -10,12 +10,16 @@ "setup.settings": "settings", "setup.base_url": "Base URL", "setup.finish": "Finish setup", - "forgot_password.title": "Reset your password", + "forgot_password.title": "Forgot password", "forgot_password.email": "Email", "forgot_password.paper_key": "Paper key", "forgot_password.email_description": "Enter your email address linked to your account. We will email you a link to reset your password.", "forgot_password.email_address": "Email address", "forgot_password.request": "Request password reset", "forgot_password.paper_key_description": "Enter your login linked to your account, with your paper key.", - "forgot_password.login": "Login" + "forgot_password.login": "Login", + "reset_password.title": "Reset your password", + "reset_password.new_password": "New password", + "reset_password.confirm_password": "Confirm new password", + "reset_password.set_password": "Set new password" } \ No newline at end of file diff --git a/crates/ezidam/static/i18n/fr.json b/crates/ezidam/static/i18n/fr.json index 99fb4be..654d942 100644 --- a/crates/ezidam/static/i18n/fr.json +++ b/crates/ezidam/static/i18n/fr.json @@ -10,12 +10,16 @@ "setup.settings": "réglages", "setup.base_url": "URL de base", "setup.finish": "Terminer la configuration", - "forgot_password.title": "Réinitialisation du mot de passe", + "forgot_password.title": "Mot de passe oublié", "forgot_password.email": "Email", "forgot_password.paper_key": "Clé papier", "forgot_password.email_description": "Entrez l'adresse email associée à votre compte. Nous allons vous envoyer par email un lien pour réinitialiser votre mot de passe.", "forgot_password.email_address": "Adresse email", "forgot_password.request": "Demander réinitialisation du mot de passe", "forgot_password.paper_key_description": "Entrez votre nom d'utilisateur, ainsi que votre clé papier.", - "forgot_password.login": "Nom d'utilisateur" + "forgot_password.login": "Nom d'utilisateur", + "reset_password.title": "Réinitialisation du mot de passe", + "reset_password.new_password": "Nouveau mot de passe", + "reset_password.confirm_password": "Confirmer le mot de passe", + "reset_password.set_password": "Enregistrer le mot de passe" } diff --git a/crates/ezidam/templates/pages/reset-password.html.tera b/crates/ezidam/templates/pages/reset-password.html.tera index 899b79f..4bd2289 100644 --- a/crates/ezidam/templates/pages/reset-password.html.tera +++ b/crates/ezidam/templates/pages/reset-password.html.tera @@ -16,27 +16,25 @@
{% endif %} -
-

Reset your password

+
+

-

Resetting password for {{ username }}

-
- - + +
- - + +
@@ -54,3 +52,7 @@ {% endblock page %} + +{% block i18n %} +localize("#reset_password_card"); +{% endblock i18n %} From 7c607ff514b93457977ad5d55893eb316d336c87 Mon Sep 17 00:00:00 2001 From: Philippe Loctaux Date: Sun, 6 Aug 2023 23:50:54 +0200 Subject: [PATCH 04/11] translated error --- crates/ezidam/static/i18n/en.json | 1 + crates/ezidam/static/i18n/fr.json | 1 + crates/ezidam/templates/pages/error.html.tera | 10 +++++++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/crates/ezidam/static/i18n/en.json b/crates/ezidam/static/i18n/en.json index 2292c28..5fec117 100644 --- a/crates/ezidam/static/i18n/en.json +++ b/crates/ezidam/static/i18n/en.json @@ -1,4 +1,5 @@ { + "error.go_home": "Go to homepage", "header.settings": "Settings", "header.admin_panel": "Admin panel", "header.logout": "Logout", diff --git a/crates/ezidam/static/i18n/fr.json b/crates/ezidam/static/i18n/fr.json index 654d942..963fa75 100644 --- a/crates/ezidam/static/i18n/fr.json +++ b/crates/ezidam/static/i18n/fr.json @@ -1,4 +1,5 @@ { + "error.go_home": "Aller à la page d'accueil", "header.settings": "Réglages", "header.admin_panel": "Console d'administration", "header.logout": "Se déconnecter", diff --git a/crates/ezidam/templates/pages/error.html.tera b/crates/ezidam/templates/pages/error.html.tera index 6e272ca..e377706 100644 --- a/crates/ezidam/templates/pages/error.html.tera +++ b/crates/ezidam/templates/pages/error.html.tera @@ -4,7 +4,7 @@
-
+
{{ http_code }}

{{ http_reason }}

@@ -14,7 +14,7 @@
@@ -25,4 +25,8 @@ -{% endblock page %} \ No newline at end of file +{% endblock page %} + +{% block i18n %} +localize("#error_page"); +{% endblock i18n %} From c4c9ebea54034d95f615927e523953eaba0fc8e8 Mon Sep 17 00:00:00 2001 From: Philippe Loctaux Date: Mon, 7 Aug 2023 19:27:33 +0200 Subject: [PATCH 05/11] translated authorize --- crates/ezidam/static/i18n/en.json | 8 ++++- crates/ezidam/static/i18n/fr.json | 8 ++++- .../templates/pages/oauth/authorize.html.tera | 29 ++++++++++--------- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/crates/ezidam/static/i18n/en.json b/crates/ezidam/static/i18n/en.json index 5fec117..69ca90b 100644 --- a/crates/ezidam/static/i18n/en.json +++ b/crates/ezidam/static/i18n/en.json @@ -22,5 +22,11 @@ "reset_password.title": "Reset your password", "reset_password.new_password": "New password", "reset_password.confirm_password": "Confirm new password", - "reset_password.set_password": "Set new password" + "reset_password.set_password": "Set new password", + "authorize.access_app": "Access [[app_name]]", + "authorize.with_account": "With your [[business_name]] account", + "authorize.login": "Login", + "authorize.password": "Password", + "authorize.authorize": "Authorize", + "authorize.forgot_password": "Forgot your password?" } \ No newline at end of file diff --git a/crates/ezidam/static/i18n/fr.json b/crates/ezidam/static/i18n/fr.json index 963fa75..02aaab7 100644 --- a/crates/ezidam/static/i18n/fr.json +++ b/crates/ezidam/static/i18n/fr.json @@ -22,5 +22,11 @@ "reset_password.title": "Réinitialisation du mot de passe", "reset_password.new_password": "Nouveau mot de passe", "reset_password.confirm_password": "Confirmer le mot de passe", - "reset_password.set_password": "Enregistrer le mot de passe" + "reset_password.set_password": "Enregistrer le mot de passe", + "authorize.access_app": "Accéder à [[app_name]]", + "authorize.with_account": "Avec votre compte [[business_name]]", + "authorize.login": "Nom d'utilisateur", + "authorize.password": "Mot de passe", + "authorize.authorize": "Autoriser", + "authorize.forgot_password": "Mot de passe oublié?" } diff --git a/crates/ezidam/templates/pages/oauth/authorize.html.tera b/crates/ezidam/templates/pages/oauth/authorize.html.tera index 7501c44..480a2da 100644 --- a/crates/ezidam/templates/pages/oauth/authorize.html.tera +++ b/crates/ezidam/templates/pages/oauth/authorize.html.tera @@ -8,7 +8,7 @@
-
+
{% include "utils/logo" %}
@@ -22,8 +22,8 @@
-

Access {{ app_name }}

-

With your {{ business_name }} account

+

+

{% if user %} @@ -39,23 +39,19 @@
{% else %}
- - + +
- +
- +
{% endif %}
@@ -63,7 +59,7 @@ {% if user %} {% else %} {% endif %}
@@ -79,3 +75,10 @@ {% endblock page %} + +{% block i18n %} +localize("#authorize_page", { + 'app_name': '{{app_name}}', + 'business_name': '{{business_name}}', +}); +{% endblock i18n %} From 411fdd7bf3448c546ff6663b4a4a36cc41fcb7db Mon Sep 17 00:00:00 2001 From: Philippe Loctaux Date: Mon, 7 Aug 2023 19:33:48 +0200 Subject: [PATCH 06/11] translated totp --- crates/ezidam/static/i18n/en.json | 5 ++++- crates/ezidam/static/i18n/fr.json | 5 ++++- crates/ezidam/templates/pages/oauth/totp.html.tera | 14 ++++++++------ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/crates/ezidam/static/i18n/en.json b/crates/ezidam/static/i18n/en.json index 69ca90b..ca58e73 100644 --- a/crates/ezidam/static/i18n/en.json +++ b/crates/ezidam/static/i18n/en.json @@ -28,5 +28,8 @@ "authorize.login": "Login", "authorize.password": "Password", "authorize.authorize": "Authorize", - "authorize.forgot_password": "Forgot your password?" + "authorize.forgot_password": "Forgot your password?", + "totp.verify_account": "Verify your account", + "totp.enter_code": "Enter the code displayed on your device", + "totp.verify_code": "Verify code" } \ No newline at end of file diff --git a/crates/ezidam/static/i18n/fr.json b/crates/ezidam/static/i18n/fr.json index 02aaab7..29221e2 100644 --- a/crates/ezidam/static/i18n/fr.json +++ b/crates/ezidam/static/i18n/fr.json @@ -28,5 +28,8 @@ "authorize.login": "Nom d'utilisateur", "authorize.password": "Mot de passe", "authorize.authorize": "Autoriser", - "authorize.forgot_password": "Mot de passe oublié?" + "authorize.forgot_password": "Mot de passe oublié?", + "totp.verify_account": "Vérification de votre compte", + "totp.enter_code": "Entrez le code de vérification sur votre appareil", + "totp.verify_code": "Verifier le code" } diff --git a/crates/ezidam/templates/pages/oauth/totp.html.tera b/crates/ezidam/templates/pages/oauth/totp.html.tera index 650d31a..5eb3de3 100644 --- a/crates/ezidam/templates/pages/oauth/totp.html.tera +++ b/crates/ezidam/templates/pages/oauth/totp.html.tera @@ -19,11 +19,11 @@
{% endif %} -
+
-

Verify your account

+

{{ user::avatar(username=username, name=name, size="lg", css="mb-3") }} @@ -38,9 +38,7 @@
- +
@@ -72,3 +70,7 @@ {% endblock page %} + +{% block i18n %} +localize("#totp_page"); +{% endblock i18n %} From 9e8c51790e18ee76d8a457a19369d0007b627718 Mon Sep 17 00:00:00 2001 From: Philippe Loctaux Date: Mon, 7 Aug 2023 19:40:26 +0200 Subject: [PATCH 07/11] translated redirect --- crates/ezidam/static/i18n/en.json | 5 ++++- crates/ezidam/static/i18n/fr.json | 5 ++++- .../ezidam/templates/pages/oauth/redirect.html.tera | 12 ++++++++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/crates/ezidam/static/i18n/en.json b/crates/ezidam/static/i18n/en.json index ca58e73..244d365 100644 --- a/crates/ezidam/static/i18n/en.json +++ b/crates/ezidam/static/i18n/en.json @@ -31,5 +31,8 @@ "authorize.forgot_password": "Forgot your password?", "totp.verify_account": "Verify your account", "totp.enter_code": "Enter the code displayed on your device", - "totp.verify_code": "Verify code" + "totp.verify_code": "Verify code", + "redirect.hello": "Hello!", + "redirect.preparing_app": "Preparing application", + "redirect.not_redirected": "Click here if you are not redirected" } \ No newline at end of file diff --git a/crates/ezidam/static/i18n/fr.json b/crates/ezidam/static/i18n/fr.json index 29221e2..73bcfb7 100644 --- a/crates/ezidam/static/i18n/fr.json +++ b/crates/ezidam/static/i18n/fr.json @@ -31,5 +31,8 @@ "authorize.forgot_password": "Mot de passe oublié?", "totp.verify_account": "Vérification de votre compte", "totp.enter_code": "Entrez le code de vérification sur votre appareil", - "totp.verify_code": "Verifier le code" + "totp.verify_code": "Verifier le code", + "redirect.hello": "Bonjour!", + "redirect.preparing_app": "Préparation de l'application", + "redirect.not_redirected": "Cliquez ici si vous n'êtes pas redirigé" } diff --git a/crates/ezidam/templates/pages/oauth/redirect.html.tera b/crates/ezidam/templates/pages/oauth/redirect.html.tera index 8f04d18..ae87d06 100644 --- a/crates/ezidam/templates/pages/oauth/redirect.html.tera +++ b/crates/ezidam/templates/pages/oauth/redirect.html.tera @@ -8,15 +8,15 @@
-
+
{% include "utils/logo" %}
-

Hello!

-

Preparing application

+

+

{{ user::avatar(username=username, name=name, size="xl", css="mb-3") }} @@ -34,7 +34,7 @@
@@ -48,3 +48,7 @@ {% endblock page %} + +{% block i18n %} +localize("#redirect_page"); +{% endblock i18n %} From 65c01fb42f0964e0a9d9086987e6563ce8eb5936 Mon Sep 17 00:00:00 2001 From: Philippe Loctaux Date: Wed, 9 Aug 2023 22:37:25 +0200 Subject: [PATCH 08/11] need to translate everything on every page --- crates/ezidam/templates/pages/homepage.html.tera | 4 ++++ crates/ezidam/templates/shell.html.tera | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/ezidam/templates/pages/homepage.html.tera b/crates/ezidam/templates/pages/homepage.html.tera index 825b2ad..c62e118 100644 --- a/crates/ezidam/templates/pages/homepage.html.tera +++ b/crates/ezidam/templates/pages/homepage.html.tera @@ -2,3 +2,7 @@ {% block content %} {% endblock content %} + +{% block i18n %} +localize("#header_user_nav"); +{% endblock i18n %} diff --git a/crates/ezidam/templates/shell.html.tera b/crates/ezidam/templates/shell.html.tera index 41c887b..a271e30 100644 --- a/crates/ezidam/templates/shell.html.tera +++ b/crates/ezidam/templates/shell.html.tera @@ -21,7 +21,3 @@ {% block additional_js %}{% endblock additional_js %} {% endblock page %} - -{% block i18n %} -localize("#header_user_nav"); -{% endblock i18n %} From b70bce66efe16c1cb635400be3f8d08a3a0492bf Mon Sep 17 00:00:00 2001 From: Philippe Loctaux Date: Wed, 9 Aug 2023 22:37:53 +0200 Subject: [PATCH 09/11] translated base of settings: header + menu items --- crates/ezidam/static/i18n/en.json | 6 ++++- crates/ezidam/static/i18n/fr.json | 6 ++++- .../pages/settings/personal.html.tera | 23 ++++++++++++------- .../pages/settings/security.html.tera | 23 ++++++++++++------- .../templates/pages/settings/visual.html.tera | 23 ++++++++++++------- 5 files changed, 55 insertions(+), 26 deletions(-) diff --git a/crates/ezidam/static/i18n/en.json b/crates/ezidam/static/i18n/en.json index 244d365..ebdb790 100644 --- a/crates/ezidam/static/i18n/en.json +++ b/crates/ezidam/static/i18n/en.json @@ -34,5 +34,9 @@ "totp.verify_code": "Verify code", "redirect.hello": "Hello!", "redirect.preparing_app": "Preparing application", - "redirect.not_redirected": "Click here if you are not redirected" + "redirect.not_redirected": "Click here if you are not redirected", + "user_settings.settings": "Settings", + "user_settings.personal": "Personal", + "user_settings.security": "Security", + "user_settings.visual": "Visual" } \ No newline at end of file diff --git a/crates/ezidam/static/i18n/fr.json b/crates/ezidam/static/i18n/fr.json index 73bcfb7..d9d0e28 100644 --- a/crates/ezidam/static/i18n/fr.json +++ b/crates/ezidam/static/i18n/fr.json @@ -34,5 +34,9 @@ "totp.verify_code": "Verifier le code", "redirect.hello": "Bonjour!", "redirect.preparing_app": "Préparation de l'application", - "redirect.not_redirected": "Cliquez ici si vous n'êtes pas redirigé" + "redirect.not_redirected": "Cliquez ici si vous n'êtes pas redirigé", + "user_settings.settings": "Réglages", + "user_settings.personal": "Personnel", + "user_settings.security": "Sécurité", + "user_settings.visual": "Visuel" } diff --git a/crates/ezidam/templates/pages/settings/personal.html.tera b/crates/ezidam/templates/pages/settings/personal.html.tera index f7c54ad..f77b361 100644 --- a/crates/ezidam/templates/pages/settings/personal.html.tera +++ b/crates/ezidam/templates/pages/settings/personal.html.tera @@ -2,13 +2,11 @@ {% block content %} -