@hyperscript-tools/multilingual 3.3.0 → 4.0.0

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +162 -0
  2. package/dist/hyperscript-i18n-ar.global.js +6 -6
  3. package/dist/hyperscript-i18n-bn.global.js +6 -6
  4. package/dist/hyperscript-i18n-de.global.js +6 -6
  5. package/dist/hyperscript-i18n-east-asian.global.js +6 -6
  6. package/dist/hyperscript-i18n-en.global.js +8 -8
  7. package/dist/hyperscript-i18n-es.global.js +6 -6
  8. package/dist/hyperscript-i18n-fr.global.js +6 -6
  9. package/dist/hyperscript-i18n-he.global.js +6 -6
  10. package/dist/hyperscript-i18n-hi.global.js +6 -6
  11. package/dist/hyperscript-i18n-id.global.js +6 -6
  12. package/dist/hyperscript-i18n-it.global.js +6 -6
  13. package/dist/hyperscript-i18n-ja.global.js +6 -6
  14. package/dist/hyperscript-i18n-ko.global.js +6 -6
  15. package/dist/hyperscript-i18n-lite.global.js +2 -2
  16. package/dist/hyperscript-i18n-ms.global.js +6 -6
  17. package/dist/hyperscript-i18n-pl.global.js +6 -6
  18. package/dist/hyperscript-i18n-pt.global.js +6 -6
  19. package/dist/hyperscript-i18n-qu.global.js +6 -6
  20. package/dist/hyperscript-i18n-ru.global.js +6 -6
  21. package/dist/hyperscript-i18n-slavic.global.js +6 -6
  22. package/dist/hyperscript-i18n-south-asian.global.js +6 -6
  23. package/dist/hyperscript-i18n-southeast-asian.global.js +6 -6
  24. package/dist/hyperscript-i18n-sw.global.js +6 -6
  25. package/dist/hyperscript-i18n-th.global.js +6 -6
  26. package/dist/hyperscript-i18n-tl.global.js +6 -6
  27. package/dist/hyperscript-i18n-tr.global.js +6 -6
  28. package/dist/hyperscript-i18n-uk.global.js +6 -6
  29. package/dist/hyperscript-i18n-vi.global.js +6 -6
  30. package/dist/hyperscript-i18n-western.global.js +6 -6
  31. package/dist/hyperscript-i18n-zh.global.js +6 -6
  32. package/dist/hyperscript-i18n.global.js +28 -28
  33. package/package.json +2 -2
@@ -1,2 +1,2 @@
1
- var HyperscriptI18n=(function(exports){'use strict';function g(e){let r=e.getAttribute("data-lang");if(r)return u(r);let t=e.getAttribute("data-hyperscript-lang")??e.closest?.("[data-hyperscript-lang]")?.getAttribute("data-hyperscript-lang");if(t)return u(t);let i=e.closest?.("[lang]")?.getAttribute("lang");if(i)return u(i);let o=typeof document<"u"?document.documentElement?.lang:null;return o&&o!=="en"?u(o):null}function u(e){return e.split("-")[0].toLowerCase()}var f=new WeakSet;function H(e){return (e.config?.attributes??"_, script, data-script").split(",").map(t=>t.trim()).filter(Boolean)}function L(e,r){for(let t of r)if(e.hasAttribute(t))return t;return null}function d(e,r){if(typeof e.addSourceTransform=="function"){e.addSourceTransform(r);return}if(typeof e.addBeforeProcessHook!="function"){console.warn("[hyperscript-i18n] _hyperscript.addBeforeProcessHook is unavailable \u2014 this build of _hyperscript.org is not supported. Load a current version from https://unpkg.com/hyperscript.org.");return}let t=H(e),i=[...t.map(n=>`[${n}]`),'script[type="text/hyperscript"]'].join(", "),o=n=>{if(f.has(n))return;if(n instanceof HTMLScriptElement&&n.type==="text/hyperscript"){let l=n.textContent??"";if(!l)return;let p=r(l,n);f.add(n),p!=null&&p!==l&&(n.textContent=p);return}let c=L(n,t);if(!c)return;let s=n.getAttribute(c);if(!s)return;let a=r(s,n);f.add(n),a!=null&&a!==s&&n.setAttribute(c,a);};e.addBeforeProcessHook(n=>{!n||typeof n.querySelectorAll!="function"||(typeof n.matches=="function"&&n.matches(i)&&o(n),n.querySelectorAll(i).forEach(o));});}var k=new Set(["me","my","i","it","its","you","your"]);function w(e){for(let r of e?.features??[])for(let t of r.events??[])if(typeof t.on=="string"&&k.has(t.on.toLowerCase()))return t.on}function y(e,r){if(typeof e.parse!="function")return true;try{let t=e.parse(r);return t?.errors&&t.errors.length>0?!1:w(t)===void 0}catch{return false}}var m=new Set;function h(e,r,t){m.has(e)||(m.add(e),console.warn(`[hyperscript-i18n] Translation for lang="${e}" rendered hyperscript the host parser rejects (or reads as a handler for an event named like me/it/you) \u2014 falling back to the original text. Source: "${r.length>60?r.slice(0,60)+"\u2026":r}" \u2192 "${t.length>60?t.slice(0,60)+"\u2026":t}". Further elements in this language stay quiet \u2014 enable { debug: true } for per-element detail.`));}function b(){if(typeof globalThis>"u")return null;let e=globalThis,r=["LokaScriptSemantic","LokaScriptSemanticPriority","LokaScriptSemanticWestern","LokaScriptSemanticEastAsian","LokaScriptSemanticEsEn","LokaScriptSemanticEn","LokaScriptSemanticEs"];for(let t of r){let i=e[t];if(i&&typeof i=="object"&&"parse"in i&&"render"in i)return i}return null}function S(e,r,t,i){try{if(t.translate)return t.translate(e,r,"en");let o=t.parse(e,r);if(o)return t.render(o,"en")}catch{}return e}function E(e={}){return function(t){let i=b();if(!i){console.warn('[hyperscript-i18n] No LokaScriptSemantic global found. Load a semantic bundle before the adapter: <script src="lokascript-semantic.browser.global.js"></script>');return}let o=t;if(d(o,(n,c)=>{let s=A(c,e);if(!s||s==="en")return n;let a=S(n,s,i);if(a!==n){if(e.validateWithHost!==false&&!y(o,a))return e.debug?console.log(`[hyperscript-i18n] ${s}: host rejected "${a}" \u2014 keeping "${n}"`):h(s,n,a),n;e.debug&&console.log(`[hyperscript-i18n] ${s}: "${n}" \u2192 "${a}"`);}return a}),e.debug){let n=i.getSupportedLanguages?.()??["(unknown)"];console.log(`[hyperscript-i18n] Lite adapter loaded. Languages: ${n.join(", ")}`);}}}function A(e,r){if(r.languageAttribute){let i=e.getAttribute(r.languageAttribute);if(i)return i.split("-")[0].toLowerCase()}let t=g(e);return t||(r.defaultLanguage??null)}function T(e,r){if(r==="en")return e;let t=b();if(!t)throw new Error("No LokaScriptSemantic global found");return S(e,r,t)}typeof _hyperscript<"u"&&_hyperscript.use&&_hyperscript.use(E());
2
- exports.hyperscriptI18n=E;exports.preprocess=T;exports.resolveLanguage=g;return exports;})({});
1
+ var HyperscriptI18n=(function(exports){'use strict';function g(e){let r=e.getAttribute("data-lang");if(r)return u(r);let t=e.getAttribute("data-hyperscript-lang")??e.closest?.("[data-hyperscript-lang]")?.getAttribute("data-hyperscript-lang");if(t)return u(t);let i=e.closest?.("[lang]")?.getAttribute("lang");if(i)return u(i);let o=typeof document<"u"?document.documentElement?.lang:null;return o&&o!=="en"?u(o):null}function u(e){return e.split("-")[0].toLowerCase()}var f=new WeakSet;function S(e){return (e.config?.attributes??"_, script, data-script").split(",").map(t=>t.trim()).filter(Boolean)}function w(e,r){for(let t of r)if(e.hasAttribute(t))return t;return null}function d(e,r){if(typeof e.addSourceTransform=="function"){e.addSourceTransform(r);return}if(typeof e.addBeforeProcessHook!="function"){console.warn("[hyperscript-i18n] _hyperscript.addBeforeProcessHook is unavailable \u2014 this build of _hyperscript.org is not supported. Load a current version from https://unpkg.com/hyperscript.org.");return}let t=S(e),i=[...t.map(n=>`[${n}]`),'script[type="text/hyperscript"]'].join(", "),o=n=>{if(f.has(n))return;if(n instanceof HTMLScriptElement&&n.type==="text/hyperscript"){let l=n.textContent??"";if(!l)return;let p=r(l,n);f.add(n),p!=null&&p!==l&&(n.textContent=p);return}let c=w(n,t);if(!c)return;let s=n.getAttribute(c);if(!s)return;let a=r(s,n);f.add(n),a!=null&&a!==s&&n.setAttribute(c,a);};e.addBeforeProcessHook(n=>{!n||typeof n.querySelectorAll!="function"||(typeof n.matches=="function"&&n.matches(i)&&o(n),n.querySelectorAll(i).forEach(o));});}var L=new Set(["me","my","i","it","its","you","your"]);function k(e){for(let r of e?.features??[])for(let t of r.events??[])if(typeof t.on=="string"&&L.has(t.on.toLowerCase()))return t.on}function m(e,r){if(typeof e.parse!="function")return true;try{let t=e.parse(r);return t?.errors&&t.errors.length>0?!1:k(t)===void 0}catch{return false}}var y=new Set;function h(e,r,t){y.has(e)||(y.add(e),console.warn(`[hyperscript-i18n] Translation for lang="${e}" rendered hyperscript the host parser rejects (or reads as a handler for an event named like me/it/you) \u2014 falling back to the original text. Source: "${r.length>60?r.slice(0,60)+"\u2026":r}" \u2192 "${t.length>60?t.slice(0,60)+"\u2026":t}". Further elements in this language stay quiet \u2014 enable { debug: true } for per-element detail.`));}function b(){if(typeof globalThis>"u")return null;let e=globalThis,r=["LokaScriptSemantic",...Object.keys(e).filter(t=>t.startsWith("LokaScriptSemantic"))];for(let t of r){let i=e[t];if(i&&typeof i=="object"&&"parse"in i&&"render"in i)return i}return null}function H(e,r,t,i){try{if(t.translate)return t.translate(e,r,"en");let o=t.parse(e,r);if(o)return t.render(o,"en")}catch{}return e}function v(e={}){return function(t){let i=b();if(!i){console.warn('[hyperscript-i18n] No LokaScriptSemantic global found. Load a semantic bundle before the adapter: <script src="lokascript-semantic.browser.global.js"></script>');return}let o=t;if(d(o,(n,c)=>{let s=A(c,e);if(!s||s==="en")return n;let a=H(n,s,i);if(a!==n){if(e.validateWithHost!==false&&!m(o,a))return e.debug?console.log(`[hyperscript-i18n] ${s}: host rejected "${a}" \u2014 keeping "${n}"`):h(s,n,a),n;e.debug&&console.log(`[hyperscript-i18n] ${s}: "${n}" \u2192 "${a}"`);}return a}),e.debug){let n=i.getSupportedLanguages?.()??["(unknown)"];console.log(`[hyperscript-i18n] Lite adapter loaded. Languages: ${n.join(", ")}`);}}}function A(e,r){if(r.languageAttribute){let i=e.getAttribute(r.languageAttribute);if(i)return i.split("-")[0].toLowerCase()}let t=g(e);return t||(r.defaultLanguage??null)}function T(e,r){if(r==="en")return e;let t=b();if(!t)throw new Error("No LokaScriptSemantic global found");return H(e,r,t)}typeof _hyperscript<"u"&&_hyperscript.use&&_hyperscript.use(v());
2
+ exports.hyperscriptI18n=v;exports.preprocess=T;exports.resolveLanguage=g;return exports;})({});