@nice2dev/i18n 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dictionaries/de.cjs +4 -1
- package/dist/dictionaries/de.mjs +6422 -1
- package/dist/dictionaries/en.cjs +4 -1
- package/dist/dictionaries/en.mjs +6422 -1
- package/dist/dictionaries/es.cjs +4 -1
- package/dist/dictionaries/es.mjs +6422 -1
- package/dist/dictionaries/fr.cjs +4 -1
- package/dist/dictionaries/fr.mjs +6422 -1
- package/dist/dictionaries/pl.cjs +4 -1
- package/dist/dictionaries/pl.mjs +6422 -1
- package/dist/dictionaries/uk.cjs +4 -1
- package/dist/dictionaries/uk.mjs +6422 -1
- package/dist/dynamic-loading.mjs +1 -1
- package/dist/i18nContext.mjs +1 -1
- package/dist/pseudo-localization.cjs +1 -1
- package/dist/pseudo-localization.mjs +19 -17
- package/dist/rtl.mjs +1 -1
- package/dist/timezone.cjs +1 -1
- package/dist/timezone.mjs +1 -1
- package/package.json +1 -1
package/dist/dynamic-loading.mjs
CHANGED
package/dist/i18nContext.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as n } from "react/jsx-runtime";
|
|
2
2
|
import { useContext as o, createContext as r } from "react";
|
|
3
|
-
const a = (e, t) => t, c = r(a), i = r("en"), u = ({ t: e, lang: t, children: s }) => /* @__PURE__ */ n(i.Provider, { value: t, children: /* @__PURE__ */ n(c.Provider, { value: e, children: s }) });
|
|
3
|
+
const a = (e, t) => t, c = /* @__PURE__ */ r(a), i = /* @__PURE__ */ r("en"), u = ({ t: e, lang: t, children: s }) => /* @__PURE__ */ n(i.Provider, { value: t, children: /* @__PURE__ */ n(c.Provider, { value: e, children: s }) });
|
|
4
4
|
function v() {
|
|
5
5
|
const e = o(c), t = o(i);
|
|
6
6
|
return { t: e, lang: t };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react/jsx-runtime"),l=require("react"),P={a:"ą",b:"ɓ",c:"ç",d:"ð",e:"ë",f:"ƒ",g:"ğ",h:"ĥ",i:"ï",j:"ĵ",k:"ķ",l:"ľ",m:"ɱ",n:"ñ",o:"ő",p:"þ",q:"ǫ",r:"ř",s:"š",t:"ŧ",u:"ü",v:"ṽ",w:"ŵ",x:"χ",y:"ÿ",z:"ž",A:"Ą",B:"Ɓ",C:"Ç",D:"Ð",E:"Ë",F:"Ƒ",G:"Ğ",H:"Ĥ",I:"Ï",J:"Ĵ",K:"Ķ",L:"Ľ",M:"Ṁ",N:"Ñ",O:"Ő",P:"Þ",Q:"Ǫ",R:"Ř",S:"Š",T:"Ŧ",U:"Ü",V:"Ṽ",W:"Ŵ",X:"Χ",Y:"Ÿ",Z:"Ž"},I={...P,a:"ặ",e:"ệ",i:"ị",o:"ộ",u:"ụ",y:"ỵ",A:"Ặ",E:"Ệ",I:"Ị",O:"Ộ",U:"Ụ",Y:"Ỵ"},z="",D="",M="",T="~∼~≈";function y(e,n=!1){const t=n?I:P;return e.split("").map(s=>t[s]||s).join("")}function F(e,n="[",t="]"){return`${n}${e}${t}`}function x(e,n=.3,t=!1){if(t)return N(e);const r=Math.ceil(e.length*(1+n))-e.length;if(r<=0)return e;const o=T[0].repeat(r);return e+o}function N(e){const n=new Set(["a","e","i","o","u","A","E","I","O","U"]);return e.split("").map(t=>n.has(t)?t+t:t).join("")}function B(e,n=!1){return n?`${D}${e}${M}`:`${z}${e}${M}`}function A(e,n={}){const{addBrackets:t=!0,expansionFactor:s=.3,addAccents:r=!0,addBidiMarkers:o=!1,useVowelDoubling:p=!1,preservePlaceholders:i=!0,preserveHtml:d=!0,prefix:c="[",suffix:m="]"}=n,k=new Map;let a=e,h=0;i&&(a=a.replace(/\{[^}]+\}/g,g=>{const u=`__PH${h++}__`;return k.set(u,g),u})),d&&(a=a.replace(/<[^>]+>/g,g=>{const u=`__PH${h++}__`;return k.set(u,g),u})),r&&(a=_(a,k)),s>0&&(a=x(a,s,p)),o&&(a=B(a)),t&&(a=`${c}${a}${m}`);for(const[g,u]of k.entries())a=a.replace(g,u);return a}function _(e,n){const t=new Set(n.keys());return e.split("").map(s=>{for(const r of t)if(e.includes(r)&&r.includes(s))return s;return P[s]||s}).join("")}function f(e){switch(e){case"accented":return{addBrackets:!0,addAccents:!0,expansionFactor:0,addBidiMarkers:!1};case"bidi":return{addBrackets:!0,addAccents:!1,expansionFactor:0,addBidiMarkers:!0};case"expansion":return{addBrackets:!0,addAccents:!1,expansionFactor:.4,addBidiMarkers:!1};case"full":default:return{addBrackets:!0,addAccents:!0,expansionFactor:.3,addBidiMarkers:!1,useVowelDoubling:!0}}}function C(e,n){const t={};for(const[s,r]of Object.entries(e))t[s]=A(r,n);return t}function L(e){return/[^\x00-\x7F]/.test(e)}function S(e){if(!e||/^[\d.,-]+$/.test(e)||e.startsWith("["))return!1;const n=/[a-zA-Z]{2,}/.test(e),t=L(e);return n&&!t}function v(e,n){const t={totalKeys:Object.keys(e).length,hardcodedStrings:[],emptyValues:[],placeholderMismatches:[],potentialIssues:0};for(const[s,r]of Object.entries(e)){if(!r||r.trim()===""){t.emptyValues.push(s),t.potentialIssues++;continue}if(S(r)&&t.hardcodedStrings.push(s),n&&n[s]){const o=E(r),p=E(n[s]),i=o.filter(c=>!p.includes(c)),d=p.filter(c=>!o.includes(c));(i.length>0||d.length>0)&&(t.placeholderMismatches.push({key:s,placeholders:[...i.map(c=>`-${c}`),...d.map(c=>`+${c}`)]}),t.potentialIssues++)}}return t}function E(e){return(e.match(/\{([^}]+)\}/g)||[]).map(t=>t.replace(/[{}]/g,"").split(",")[0].trim())}const $=l.createContext(null);function j({children:e,initialEnabled:n=!1,initialMode:t="full"}){const[s,r]=l.useState(n),[o,p]=l.useState(t),i=l.useMemo(()=>f(o),[o]),d=l.useMemo(()=>m=>s?A(m,i):m,[s,i]),c=l.useMemo(()=>({enabled:s,mode:o,options:i,toggle:()=>r(m=>!m),setMode:p,transform:d}),[s,o,i,d]);return b.jsx($.Provider,{value:c,children:e})}function w(){const e=l.useContext($);return e||{enabled:!1,mode:"full",options:f("full"),toggle:()=>{},setMode:()=>{},transform:n=>n}}const O={MINIMAL:{addBrackets:!0,addAccents:!1,expansionFactor:0},ACCENTED:f("accented"),EXPANDED:f("expansion"),BIDI:f("bidi"),FULL:f("full"),FINNISH:{addBrackets:!0,addAccents:!0,expansionFactor:.4},GERMAN:{addBrackets:!0,addAccents:!0,expansionFactor:.35},CJK:{addBrackets:!0,addAccents:!1,expansionFactor:-.1}};exports.PSEUDO_PRESETS=O;exports.PseudoLocalizationProvider=j;exports.addAccents=y;exports.addBidiMarkers=B;exports.addBrackets=F;exports.analyzeDictionary=v;exports.containsNonAscii=L;exports.detectHardcodedText=S;exports.expandText=x;exports.getPseudoLocalizationPreset=f;exports.pseudoLocalize=A;exports.pseudoLocalizeDictionary=C;exports.usePseudoLocalization=w;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react/jsx-runtime"),l=require("react"),P={a:"ą",b:"ɓ",c:"ç",d:"ð",e:"ë",f:"ƒ",g:"ğ",h:"ĥ",i:"ï",j:"ĵ",k:"ķ",l:"ľ",m:"ɱ",n:"ñ",o:"ő",p:"þ",q:"ǫ",r:"ř",s:"š",t:"ŧ",u:"ü",v:"ṽ",w:"ŵ",x:"χ",y:"ÿ",z:"ž",A:"Ą",B:"Ɓ",C:"Ç",D:"Ð",E:"Ë",F:"Ƒ",G:"Ğ",H:"Ĥ",I:"Ï",J:"Ĵ",K:"Ķ",L:"Ľ",M:"Ṁ",N:"Ñ",O:"Ő",P:"Þ",Q:"Ǫ",R:"Ř",S:"Š",T:"Ŧ",U:"Ü",V:"Ṽ",W:"Ŵ",X:"Χ",Y:"Ÿ",Z:"Ž"},I=(function(){return{...P,a:"ặ",e:"ệ",i:"ị",o:"ộ",u:"ụ",y:"ỵ",A:"Ặ",E:"Ệ",I:"Ị",O:"Ộ",U:"Ụ",Y:"Ỵ"}})(),z="",D="",M="",T="~∼~≈";function y(e,n=!1){const t=n?I:P;return e.split("").map(s=>t[s]||s).join("")}function F(e,n="[",t="]"){return`${n}${e}${t}`}function x(e,n=.3,t=!1){if(t)return N(e);const r=Math.ceil(e.length*(1+n))-e.length;if(r<=0)return e;const o=T[0].repeat(r);return e+o}function N(e){const n=new Set(["a","e","i","o","u","A","E","I","O","U"]);return e.split("").map(t=>n.has(t)?t+t:t).join("")}function B(e,n=!1){return n?`${D}${e}${M}`:`${z}${e}${M}`}function A(e,n={}){const{addBrackets:t=!0,expansionFactor:s=.3,addAccents:r=!0,addBidiMarkers:o=!1,useVowelDoubling:p=!1,preservePlaceholders:i=!0,preserveHtml:d=!0,prefix:c="[",suffix:m="]"}=n,k=new Map;let a=e,h=0;i&&(a=a.replace(/\{[^}]+\}/g,g=>{const u=`__PH${h++}__`;return k.set(u,g),u})),d&&(a=a.replace(/<[^>]+>/g,g=>{const u=`__PH${h++}__`;return k.set(u,g),u})),r&&(a=_(a,k)),s>0&&(a=x(a,s,p)),o&&(a=B(a)),t&&(a=`${c}${a}${m}`);for(const[g,u]of k.entries())a=a.replace(g,u);return a}function _(e,n){const t=new Set(n.keys());return e.split("").map(s=>{for(const r of t)if(e.includes(r)&&r.includes(s))return s;return P[s]||s}).join("")}function f(e){switch(e){case"accented":return{addBrackets:!0,addAccents:!0,expansionFactor:0,addBidiMarkers:!1};case"bidi":return{addBrackets:!0,addAccents:!1,expansionFactor:0,addBidiMarkers:!0};case"expansion":return{addBrackets:!0,addAccents:!1,expansionFactor:.4,addBidiMarkers:!1};case"full":default:return{addBrackets:!0,addAccents:!0,expansionFactor:.3,addBidiMarkers:!1,useVowelDoubling:!0}}}function C(e,n){const t={};for(const[s,r]of Object.entries(e))t[s]=A(r,n);return t}function L(e){return/[^\x00-\x7F]/.test(e)}function S(e){if(!e||/^[\d.,-]+$/.test(e)||e.startsWith("["))return!1;const n=/[a-zA-Z]{2,}/.test(e),t=L(e);return n&&!t}function v(e,n){const t={totalKeys:Object.keys(e).length,hardcodedStrings:[],emptyValues:[],placeholderMismatches:[],potentialIssues:0};for(const[s,r]of Object.entries(e)){if(!r||r.trim()===""){t.emptyValues.push(s),t.potentialIssues++;continue}if(S(r)&&t.hardcodedStrings.push(s),n&&n[s]){const o=E(r),p=E(n[s]),i=o.filter(c=>!p.includes(c)),d=p.filter(c=>!o.includes(c));(i.length>0||d.length>0)&&(t.placeholderMismatches.push({key:s,placeholders:[...i.map(c=>`-${c}`),...d.map(c=>`+${c}`)]}),t.potentialIssues++)}}return t}function E(e){return(e.match(/\{([^}]+)\}/g)||[]).map(t=>t.replace(/[{}]/g,"").split(",")[0].trim())}const $=l.createContext(null);function j({children:e,initialEnabled:n=!1,initialMode:t="full"}){const[s,r]=l.useState(n),[o,p]=l.useState(t),i=l.useMemo(()=>f(o),[o]),d=l.useMemo(()=>m=>s?A(m,i):m,[s,i]),c=l.useMemo(()=>({enabled:s,mode:o,options:i,toggle:()=>r(m=>!m),setMode:p,transform:d}),[s,o,i,d]);return b.jsx($.Provider,{value:c,children:e})}function w(){const e=l.useContext($);return e||{enabled:!1,mode:"full",options:f("full"),toggle:()=>{},setMode:()=>{},transform:n=>n}}const O={MINIMAL:{addBrackets:!0,addAccents:!1,expansionFactor:0},ACCENTED:f("accented"),EXPANDED:f("expansion"),BIDI:f("bidi"),FULL:f("full"),FINNISH:{addBrackets:!0,addAccents:!0,expansionFactor:.4},GERMAN:{addBrackets:!0,addAccents:!0,expansionFactor:.35},CJK:{addBrackets:!0,addAccents:!1,expansionFactor:-.1}};exports.PSEUDO_PRESETS=O;exports.PseudoLocalizationProvider=j;exports.addAccents=y;exports.addBidiMarkers=B;exports.addBrackets=F;exports.analyzeDictionary=v;exports.containsNonAscii=L;exports.detectHardcodedText=S;exports.expandText=x;exports.getPseudoLocalizationPreset=f;exports.pseudoLocalize=A;exports.pseudoLocalizeDictionary=C;exports.usePseudoLocalization=w;
|
|
@@ -55,22 +55,24 @@ const A = {
|
|
|
55
55
|
X: "Χ",
|
|
56
56
|
Y: "Ÿ",
|
|
57
57
|
Z: "Ž"
|
|
58
|
-
}, F = {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
58
|
+
}, F = /* @__PURE__ */ (function() {
|
|
59
|
+
return {
|
|
60
|
+
...A,
|
|
61
|
+
// Additional mappings
|
|
62
|
+
a: "ặ",
|
|
63
|
+
e: "ệ",
|
|
64
|
+
i: "ị",
|
|
65
|
+
o: "ộ",
|
|
66
|
+
u: "ụ",
|
|
67
|
+
y: "ỵ",
|
|
68
|
+
A: "Ặ",
|
|
69
|
+
E: "Ệ",
|
|
70
|
+
I: "Ị",
|
|
71
|
+
O: "Ộ",
|
|
72
|
+
U: "Ụ",
|
|
73
|
+
Y: "Ỵ"
|
|
74
|
+
};
|
|
75
|
+
})(), L = "", N = "", M = "", _ = "~∼~≈";
|
|
74
76
|
function j(e, n = !1) {
|
|
75
77
|
const t = n ? F : A;
|
|
76
78
|
return e.split("").map((s) => t[s] || s).join("");
|
|
@@ -205,7 +207,7 @@ function V(e, n) {
|
|
|
205
207
|
function E(e) {
|
|
206
208
|
return (e.match(/\{([^}]+)\}/g) || []).map((t) => t.replace(/[{}]/g, "").split(",")[0].trim());
|
|
207
209
|
}
|
|
208
|
-
const B = b(null);
|
|
210
|
+
const B = /* @__PURE__ */ b(null);
|
|
209
211
|
function R({
|
|
210
212
|
children: e,
|
|
211
213
|
initialEnabled: n = !1,
|
package/dist/rtl.mjs
CHANGED
package/dist/timezone.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react"),O=require("./locale.cjs"),w={UTC:["UTC","Etc/UTC","Etc/GMT"],NorthAmerica:["America/New_York","America/Chicago","America/Denver","America/Los_Angeles","America/Toronto","America/Vancouver","America/Mexico_City"],SouthAmerica:["America/Sao_Paulo","America/Buenos_Aires","America/Lima","America/Bogota","America/Santiago"],Europe:["Europe/London","Europe/Paris","Europe/Berlin","Europe/Rome","Europe/Madrid","Europe/Amsterdam","Europe/Warsaw","Europe/Moscow","Europe/Kiev","Europe/Stockholm","Europe/Prague","Europe/Budapest","Europe/Bucharest"],Asia:["Asia/Tokyo","Asia/Shanghai","Asia/Hong_Kong","Asia/Singapore","Asia/Seoul","Asia/Kolkata","Asia/Dubai","Asia/Riyadh","Asia/Tehran","Asia/Bangkok","Asia/Jakarta"],Africa:["Africa/Cairo","Africa/Lagos","Africa/Johannesburg","Africa/Nairobi","Africa/Casablanca"],Oceania:["Australia/Sydney","Australia/Melbourne","Australia/Perth","Pacific/Auckland","Pacific/Fiji"]};function T(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return"UTC"}}function P(e){try{return new Intl.DateTimeFormat("en",{timeZone:e}),!0}catch{return!1}}function m(e,o="en",t=new Date){var b,E;const n=O.getLocaleTag(o),a=new Intl.DateTimeFormat(n,{timeZone:e,timeZoneName:"long"}),r=new Intl.DateTimeFormat(n,{timeZone:e,timeZoneName:"short"}),i=a.formatToParts(t),s=r.formatToParts(t),l=((b=i.find(S=>S.type==="timeZoneName"))==null?void 0:b.value)||e,g=((E=s.find(S=>S.type==="timeZoneName"))==null?void 0:E.value)||e,c=new Date(t.toLocaleString("en-US",{timeZone:"UTC"})),A=new Date(t.toLocaleString("en-US",{timeZone:e})),u=Math.round((A.getTime()-c.getTime())/6e4),D=new Date(t.getFullYear(),0,1),M=new Date(t.getFullYear(),6,1),Z=h(e,D),U=h(e,M),v=h(e,t),N=Math.min(Z,U),z=v!==N&&Z!==U;return{id:e,displayName:l,shortName:g,offsetMinutes:u,offsetString:_(u),isDST:z}}function I(e="en",o=new Date){return Object.values(w).flat().map(n=>m(n,e,o))}function L(e="en",o=new Date){const t={};for(const[n,a]of Object.entries(w))t[n]=a.map(r=>m(r,e,o));return t}function p(e,o,t){const n=e.toLocaleString("en-US",{timeZone:o}),a=new Date(n),r=e.toLocaleString("en-US",{timeZone:t}),i=new Date(r),s=a.getTime()-i.getTime();return new Date(e.getTime()+s)}function F(e,o){const t=o||T();return p(e,t,"UTC")}function y(e,o){const t=o||T();return p(e,"UTC",t)}function C(e,o,t={}){const n=O.getLocaleTag(e),{dateStyle:a="medium",timeStyle:r="short",nameStyle:i="short"}=t,s=new Intl.DateTimeFormat(n,{timeZone:o,dateStyle:a,timeStyle:r}),l=new Intl.DateTimeFormat(n,{timeZone:o,dateStyle:a,timeStyle:r,timeZoneName:i}),g=new Intl.DateTimeFormat(n,{timeZone:o,timeZoneName:"short"});return{format:c=>s.format(c),formatWithZone:c=>l.format(c),getOffset:c=>m(o,e,c).offsetString,getAbbreviation:c=>{var u;return((u=g.formatToParts(c).find(D=>D.type==="timeZoneName"))==null?void 0:u.value)||""}}}function f(e,o=new Date){return m(e,"en",o).isDST}function k(e,o=new Date){const t=f(e,o),n=new Date(o),a=new Date(o);for(a.setFullYear(a.getFullYear()+1);n<a;)if(n.setDate(n.getDate()+1),f(e,n)!==t){n.setDate(n.getDate()-1);const r=new Date(n);r.setHours(0,0,0,0);const i=new Date(n);for(i.setDate(i.getDate()+2);i.getTime()-r.getTime()>6e4;){const s=new Date((r.getTime()+i.getTime())/2);f(e,s)===t?r.setTime(s.getTime()):i.setTime(s.getTime())}return i}return null}function j(e,o,t){const[n]=d.useState(()=>T()),a=o||n,r=d.useMemo(()=>C(e,a,t),[e,a,t]),i=d.useMemo(()=>m(a,e),[a,e]);return{timezone:a,info:i,format:r.format,formatWithZone:r.formatWithZone,getOffset:r.getOffset,getAbbreviation:r.getAbbreviation,toUTC:s=>F(s,a),fromUTC:s=>y(s,a)}}function h(e,o){const t=o.toLocaleString("en-US",{timeZone:"UTC"}),n=o.toLocaleString("en-US",{timeZone:e}),a=new Date(t),r=new Date(n);return Math.round((r.getTime()-a.getTime())/6e4)}function _(e){const o=e>=0?"+":"-",t=Math.abs(e),n=Math.floor(t/60),a=t%60;return`${o}${n.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}`}exports.TIMEZONE_GROUPS=w;exports.convertTimezone=p;exports.createTimezoneFormatter=C;exports.detectTimezone=T;exports.fromUTC=y;exports.getAllTimezones=I;exports.getNextDSTTransition=k;exports.getTimezoneInfo=m;exports.getTimezonesGrouped=L;exports.isDSTActive=f;exports.isValidTimezone=P;exports.toUTC=F;exports.useTimezone=j;
|
package/dist/timezone.mjs
CHANGED