@joystick.js/node-canary 0.0.0-canary.456 → 0.0.0-canary.458

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.
@@ -1 +1 @@
1
- import p from"fs";import _ from"./dynamic_import.js";import o from"./get_platform_safe_path.js";import h from"../app/settings/load.js";import d from"./path_exists.js";import m from"./types.js";const l=h(),$=async(t="",n="",a="")=>{const r=await _(`${n}/i18n/${t}?v=${new Date().getTime()}`);if(console.log({language_file:r}),r&&m.is_object(r)){const e=r[a];return e||r}return{}},w=(t="",n=[],a="")=>{let r=[];t&&r.push(t);const s=n?.filter(e=>!e?.includes("*"));return r.push(...s),(l?.config?.i18n?.defaultLanguage||l?.config?.i18n?.default_language)&&r.push(l?.config?.i18n?.defaultLanguage||l?.config?.i18n?.default_language),r?.flatMap(e=>{const i=[e];return e?.length===2&&i.push(`${e.substring(0,2)}-`),e?.length>2&&(i.push(`${e?.split("-")[0]}`),i.push(`${e?.split("-")[0]}-`)),i})?.map(e=>e[e.length-1]==="-"?new RegExp(a?`^${a}_${e}[A-Z]+.js`:`^${e}[A-Z]+.js`,"g"):new RegExp(a?`^${a}_${e}.js`:`^${e}.js`,"g"))},b=(t="")=>t.split(",")?.map(a=>a.split(";")[0]),j=async(t={})=>{const n=t?.is_email?o(`${t?.joystick_build_path}i18n/email`):o(`${t?.joystick_build_path}i18n`),a=await d(n)&&p.readdirSync(n)||[],r=t?.is_email?[]:b(t?.req?.headers["accept-language"]),s=w(t?.req?.context?.user?.language,r,t?.email_template_name);console.log({language_files_path:n,language_files:a,language_preferences:s});let e=null;for(let c=0;c<s.length;c+=1){const u=s[c],f=a.find(g=>!!g.match(u));if(f){e=f;break}}return(e?await $(e,t?.joystick_build_path,t?.render_component_path):null)||{}};var E=j;export{E as default};
1
+ import o from"fs";import h from"./dynamic_import.js";import u from"./get_platform_safe_path.js";import d from"../app/settings/load.js";import g from"./path_exists.js";import m from"./types.js";const l=d(),$=async(t="",n="",r="")=>{const a=await h(`${n}/i18n/${t}?v=${new Date().getTime()}`);if(console.log({language_file:a}),a&&m.is_object(a)){const e=a[r];return e||a}return{}},w=(t="",n=[],r="")=>{let a=[];t&&a.push(t);const s=n?.filter(e=>!e?.includes("*"));return a.push(...s),(l?.config?.i18n?.defaultLanguage||l?.config?.i18n?.default_language)&&a.push(l?.config?.i18n?.defaultLanguage||l?.config?.i18n?.default_language),a?.flatMap(e=>{const i=[e];return e?.length===2&&i.push(`${e.substring(0,2)}-`),e?.length>2&&(i.push(`${e?.split("-")[0]}`),i.push(`${e?.split("-")[0]}-`)),i})?.map(e=>e[e.length-1]==="-"?new RegExp(r?`^${r}_${e}[A-Z]+.js`:`^${e}[A-Z]+.js`,"g"):new RegExp(r?`^${r}_${e}.js`:`^${e}.js`,"g"))},b=(t="")=>t.split(",")?.map(r=>r.split(";")[0]),y=async(t={})=>{const n=t?.is_email?u(`${t?.joystick_build_path}i18n/email`):u(`${t?.joystick_build_path}i18n`);console.log({language_files_path:await g(n),file_list:o.readdirSync(n)});const r=await g(n)&&o.readdirSync(n)||[],a=t?.is_email?[]:b(t?.req?.headers["accept-language"]),s=w(t?.req?.context?.user?.language,a,t?.email_template_name);console.log({language_files_path:n,language_files:r,language_preferences:s});let e=null;for(let c=0;c<s.length;c+=1){const _=s[c],f=r.find(p=>!!p.match(_));if(f){e=f;break}}return(e?await $(e,t?.joystick_build_path,t?.render_component_path):null)||{}};var E=y;export{E as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@joystick.js/node-canary",
3
3
  "type": "module",
4
- "version": "0.0.0-canary.456",
4
+ "version": "0.0.0-canary.458",
5
5
  "description": "The Node.js framework for Joystick.",
6
6
  "main": "./dist/index.js",
7
7
  "scripts": {
@@ -78,6 +78,8 @@ const get_translations = async (get_translations_options = {}) => {
78
78
  get_platform_safe_path(`${get_translations_options?.joystick_build_path}i18n/email`) :
79
79
  get_platform_safe_path(`${get_translations_options?.joystick_build_path}i18n`);
80
80
 
81
+ console.log({ language_files_path: await path_exists(language_files_path), file_list: fs.readdirSync(language_files_path) });
82
+
81
83
  const language_files = (await path_exists(language_files_path) && fs.readdirSync(language_files_path)) || [];
82
84
  const browser_languages = get_translations_options?.is_email ? [] : parse_browser_languages(get_translations_options?.req?.headers['accept-language']);
83
85
  const language_preferences = get_language_preference_regexes(