@arch-cadre/intl 0.0.40 → 0.0.41

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arch-cadre/intl",
3
- "version": "0.0.40",
3
+ "version": "0.0.41",
4
4
  "type": "module",
5
5
  "description": "Core Intl for Kryo framework",
6
6
  "types": "./dist/index.d.ts",
@@ -1 +0,0 @@
1
- "use client";import{formatMessage as e,getNestedMessage as t}from"../shared/utils.mjs";import*as n from"react";import{createContext as r,useContext as i}from"react";const a=Symbol.for(`kryo-intl-context`),o=globalThis[a]||r(null);globalThis[a]||(globalThis[a]=o);function s({children:e,locale:t,messages:r}){return n.createElement(o.Provider,{value:{locale:t,messages:r}},e)}function c(){let e=i(o);if(!e)throw Error(`useLocale must be used within I18nProvider`);return e.locale}function l(){let n=i(o);if(!n)throw Error(`useTranslation must be used within I18nProvider`);let{messages:r,locale:a}=n;return{t:(n,i)=>{let a=t(r,String(n));return typeof a==`string`?e(a,i):String(n)},locale:a}}const u=l;export{s as I18nProvider,c as useLocale,l as useTranslation,u as useTranslations};
package/dist/index.mjs DELETED
@@ -1 +0,0 @@
1
- import{formatMessage as e,getNestedMessage as t,i18n as n}from"./shared/utils.mjs";import{I18nProvider as r,useLocale as i,useTranslation as a,useTranslations as o}from"./client/index.mjs";import{COOKIE_NAME as s,DEFAULT_LOCALE as c,LOCALES as l}from"./shared/constants.mjs";export{s as COOKIE_NAME,c as DEFAULT_LOCALE,r as I18nProvider,l as LOCALES,e as formatMessage,t as getNestedMessage,n as i18n,i as useLocale,a as useTranslation,o as useTranslations};
@@ -1 +0,0 @@
1
- import{formatMessage as e,getNestedMessage as t}from"../shared/utils.mjs";import{I18nProvider as n}from"../client/index.mjs";import{COOKIE_NAME as r,DEFAULT_LOCALE as i}from"../shared/constants.mjs";import{discoverLocalePaths as a,getModuleLocalePaths as o}from"./module-loader.mjs";import s from"react";import c from"node:fs/promises";import l from"node:path";import{match as u}from"@formatjs/intl-localematcher";import d from"negotiator";import{cookies as f,headers as p}from"next/headers";function m(e,t){let n={...e};for(let r of Object.keys(t))t[r]instanceof Object&&r in e&&e[r]instanceof Object?n[r]=m(e[r],t[r]):n[r]=t[r];return n}let h=null;function g(e){h=Array.from(new Set([...h||[],...e]))}async function _(e,t){(h===null||h.length===0)&&g(await a());let n={},r=l.join(process.cwd(),`locales`),i=new Set;if(h)for(let e of h)i.add(e);if(t)for(let e of t)i.add(e);i.add(r);for(let t of Array.from(i)){let r=l.join(t,e);try{await c.access(r);let e=await c.readdir(r);for(let t of e)if(t.endsWith(`on`)){let e=l.join(r,t),i=await c.readFile(e,`utf-8`),a=JSON.parse(i);n=m(n,a)}}catch{}}return n}function v(e,t){let n=p();return u(new d({headers:Object.fromEntries(n.entries())}).languages(),e,t)}async function y({children:e}){let t=(await f()).get(r)?.value||i,a=await _(t);return s.createElement(n,{locale:t,messages:a},e)}async function b(){let n=(await f()).get(r)?.value||i,a=await _(n);return{t:(n,r)=>{let i=t(a,String(n));return typeof i==`string`?e(i,r):String(n)},locale:n}}export{y as I18nProvider,v as detectLocale,a as discoverLocalePaths,_ as getMessages,o as getModuleLocalePaths,b as getTranslation,g as registerLocalePaths};
@@ -1 +0,0 @@
1
- import e from"node:fs/promises";import t from"node:path";import"server-only";async function n(){let n=[],r=process.cwd(),i=await(async n=>{let r=[`pnpm-workspace.yaml`,`packageon`],i=n;for(console.log(`[intl]: Searching for monorepo root starting from: ${n}`);i!==t.parse(i).root;){for(let n of r)try{if(await e.access(t.join(i,n)),n===`pnpm-workspace.yaml`)return i}catch{}i=t.dirname(i)}return null})(r);if(i){let r=t.join(i,`packages`);try{let i=await e.readdir(r,{withFileTypes:!0});for(let a of i)if(a.isDirectory()){let i=t.join(r,a.name,`locales`);try{await e.access(i),n.push(i)}catch{}}}catch{}}let a=t.join(r,`node_modules`,`@arch-cadre`);try{let r=await e.readdir(a,{withFileTypes:!0});for(let i of r){let r=t.join(a,i.name,`locales`);try{await e.access(r),n.push(r)}catch{}}}catch{}let o=t.join(r,`modules`);try{let r=await e.readdir(o,{withFileTypes:!0});for(let i of r)if(i.isDirectory()){let r=t.join(o,i.name,`locales`);try{await e.access(r),n.push(r)}catch{}}}catch{}return Array.from(new Set(n))}async function r(e=[],t=`modules`){return n()}export{n as discoverLocalePaths,r as getModuleLocalePaths};
@@ -1 +0,0 @@
1
- const e=`NEXT_LOCALE`,t=`en`,n=[`en`,`pl`];export{e as COOKIE_NAME,t as DEFAULT_LOCALE,n as LOCALES};
@@ -1 +0,0 @@
1
- function e(e,t){if(!e)return;if(t in e)return e[t];let n=t.split(`.`),r=e,i=0;for(;i<n.length;){if(typeof r!=`object`||!r)return;let e=!1;for(let t=n.length;t>i;t--){let a=n.slice(i,t).join(`.`);if(a in r){r=r[a],i=t,e=!0;break}}if(!e)return}return r}function t(e,t){return t?e.replace(/{(\w+)}/g,(e,n)=>t[n]===void 0?e:String(t[n])):e}const n=e=>e;export{t as formatMessage,e as getNestedMessage,n as i18n};