@arch-cadre/intl 0.0.20 → 0.0.22
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/index.cjs +7 -2
- package/dist/index.d.cts +2 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +3 -2
- package/dist/server/index.cjs +4 -6
- package/dist/server/index.d.cts +2 -2
- package/dist/server/index.d.cts.map +1 -1
- package/dist/server/index.d.mts +2 -2
- package/dist/server/index.d.mts.map +1 -1
- package/dist/server/index.mjs +4 -6
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/module-loader.d.cts.map +1 -1
- package/dist/server/module-loader.d.mts.map +1 -1
- package/dist/server/module-loader.mjs.map +1 -1
- package/package.json +2 -5
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_constants = require('./shared/constants.cjs');
|
|
3
2
|
const require_utils = require('./shared/utils.cjs');
|
|
3
|
+
const require_client_index = require('./client/index.cjs');
|
|
4
|
+
const require_constants = require('./shared/constants.cjs');
|
|
4
5
|
|
|
5
6
|
exports.COOKIE_NAME = require_constants.COOKIE_NAME;
|
|
6
7
|
exports.DEFAULT_LOCALE = require_constants.DEFAULT_LOCALE;
|
|
8
|
+
exports.I18nProvider = require_client_index.I18nProvider;
|
|
7
9
|
exports.LOCALES = require_constants.LOCALES;
|
|
8
10
|
exports.formatMessage = require_utils.formatMessage;
|
|
9
11
|
exports.getNestedMessage = require_utils.getNestedMessage;
|
|
10
|
-
exports.i18n = require_utils.i18n;
|
|
12
|
+
exports.i18n = require_utils.i18n;
|
|
13
|
+
exports.useLocale = require_client_index.useLocale;
|
|
14
|
+
exports.useTranslation = require_client_index.useTranslation;
|
|
15
|
+
exports.useTranslations = require_client_index.useTranslations;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AbstractIntlMessages, IntlMessages, NestedKeyOf, TranslationKeys } from "./types.cjs";
|
|
2
|
+
import { I18nProvider, useLocale, useTranslation, useTranslations } from "./client/index.cjs";
|
|
2
3
|
import { COOKIE_NAME, DEFAULT_LOCALE, LOCALES } from "./shared/constants.cjs";
|
|
3
4
|
import { formatMessage, getNestedMessage, i18n } from "./shared/utils.cjs";
|
|
4
|
-
export { AbstractIntlMessages, COOKIE_NAME, DEFAULT_LOCALE, IntlMessages, LOCALES, NestedKeyOf, TranslationKeys, formatMessage, getNestedMessage, i18n };
|
|
5
|
+
export { AbstractIntlMessages, COOKIE_NAME, DEFAULT_LOCALE, I18nProvider, IntlMessages, LOCALES, NestedKeyOf, TranslationKeys, formatMessage, getNestedMessage, i18n, useLocale, useTranslation, useTranslations };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AbstractIntlMessages, IntlMessages, NestedKeyOf, TranslationKeys } from "./types.mjs";
|
|
2
|
+
import { I18nProvider, useLocale, useTranslation, useTranslations } from "./client/index.mjs";
|
|
2
3
|
import { COOKIE_NAME, DEFAULT_LOCALE, LOCALES } from "./shared/constants.mjs";
|
|
3
4
|
import { formatMessage, getNestedMessage, i18n } from "./shared/utils.mjs";
|
|
4
|
-
export { AbstractIntlMessages, COOKIE_NAME, DEFAULT_LOCALE, IntlMessages, LOCALES, NestedKeyOf, TranslationKeys, formatMessage, getNestedMessage, i18n };
|
|
5
|
+
export { AbstractIntlMessages, COOKIE_NAME, DEFAULT_LOCALE, I18nProvider, IntlMessages, LOCALES, NestedKeyOf, TranslationKeys, formatMessage, getNestedMessage, i18n, useLocale, useTranslation, useTranslations };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { COOKIE_NAME, DEFAULT_LOCALE, LOCALES } from "./shared/constants.mjs";
|
|
2
1
|
import { formatMessage, getNestedMessage, i18n } from "./shared/utils.mjs";
|
|
2
|
+
import { I18nProvider, useLocale, useTranslation, useTranslations } from "./client/index.mjs";
|
|
3
|
+
import { COOKIE_NAME, DEFAULT_LOCALE, LOCALES } from "./shared/constants.mjs";
|
|
3
4
|
|
|
4
|
-
export { COOKIE_NAME, DEFAULT_LOCALE, LOCALES, formatMessage, getNestedMessage, i18n };
|
|
5
|
+
export { COOKIE_NAME, DEFAULT_LOCALE, I18nProvider, LOCALES, formatMessage, getNestedMessage, i18n, useLocale, useTranslation, useTranslations };
|
package/dist/server/index.cjs
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
"use server";
|
|
2
|
-
|
|
3
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
2
|
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
5
|
-
const require_constants = require('../shared/constants.cjs');
|
|
6
3
|
const require_utils = require('../shared/utils.cjs');
|
|
7
4
|
const require_client_index = require('../client/index.cjs');
|
|
5
|
+
const require_constants = require('../shared/constants.cjs');
|
|
8
6
|
const require_module_loader = require('./module-loader.cjs');
|
|
9
7
|
let react = require("react");
|
|
10
8
|
react = require_runtime.__toESM(react);
|
|
@@ -29,7 +27,7 @@ let registeredPaths = null;
|
|
|
29
27
|
* Register additional directories to search for locales.
|
|
30
28
|
* Can be called multiple times, but usually called once in RootLayout.
|
|
31
29
|
*/
|
|
32
|
-
|
|
30
|
+
function registerLocalePaths(paths) {
|
|
33
31
|
registeredPaths = Array.from(new Set([...registeredPaths || [], ...paths]));
|
|
34
32
|
}
|
|
35
33
|
async function getMessages(locale, searchDirectories) {
|
|
@@ -55,8 +53,8 @@ async function getMessages(locale, searchDirectories) {
|
|
|
55
53
|
}
|
|
56
54
|
return messages;
|
|
57
55
|
}
|
|
58
|
-
|
|
59
|
-
const headerList =
|
|
56
|
+
function detectLocale(supportedLocales, defaultLocale) {
|
|
57
|
+
const headerList = (0, next_headers.headers)();
|
|
60
58
|
return (0, _formatjs_intl_localematcher.match)(new negotiator.default({ headers: Object.fromEntries(headerList.entries()) }).languages(), supportedLocales, defaultLocale);
|
|
61
59
|
}
|
|
62
60
|
/**
|
package/dist/server/index.d.cts
CHANGED
|
@@ -7,9 +7,9 @@ import React from "react";
|
|
|
7
7
|
* Register additional directories to search for locales.
|
|
8
8
|
* Can be called multiple times, but usually called once in RootLayout.
|
|
9
9
|
*/
|
|
10
|
-
declare function registerLocalePaths(paths: string[]):
|
|
10
|
+
declare function registerLocalePaths(paths: string[]): void;
|
|
11
11
|
declare function getMessages(locale: string, searchDirectories?: string[]): Promise<AbstractIntlMessages>;
|
|
12
|
-
declare function detectLocale(supportedLocales: string[], defaultLocale: string):
|
|
12
|
+
declare function detectLocale(supportedLocales: string[], defaultLocale: string): string;
|
|
13
13
|
/**
|
|
14
14
|
* Smart Server Component that handles locale detection and message loading automatically.
|
|
15
15
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/server/index.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/server/index.ts"],"mappings":";;;;;;;;AAuCA;iBAAgB,mBAAA,CAAoB,KAAA;AAAA,iBAId,WAAA,CACpB,MAAA,UACA,iBAAA,cAA4B,OAAA,CAAA,oBAAA;AAAA,iBA8Cd,YAAA,CACd,gBAAA,YACA,aAAA;;AAlDF;;iBA+DsB,YAAA,CAAA;EACpB;AAAA;EAEA,QAAA,EAAU,KAAA,CAAM,SAAA;AAAA,IACjB,OAAA,CAAA,KAAA,CAAA,wBAAA,CAAA,KAAA,CAAA,mBAAA,CAAA,gBAAA,GAAA,gBAAA;AAAA,iBAWqB,cAAA,CAAA,GAAc,OAAA;WAQlB,eAAA,EAAe,MAAA,GAAW,MAAA"}
|
package/dist/server/index.d.mts
CHANGED
|
@@ -7,9 +7,9 @@ import React from "react";
|
|
|
7
7
|
* Register additional directories to search for locales.
|
|
8
8
|
* Can be called multiple times, but usually called once in RootLayout.
|
|
9
9
|
*/
|
|
10
|
-
declare function registerLocalePaths(paths: string[]):
|
|
10
|
+
declare function registerLocalePaths(paths: string[]): void;
|
|
11
11
|
declare function getMessages(locale: string, searchDirectories?: string[]): Promise<AbstractIntlMessages>;
|
|
12
|
-
declare function detectLocale(supportedLocales: string[], defaultLocale: string):
|
|
12
|
+
declare function detectLocale(supportedLocales: string[], defaultLocale: string): string;
|
|
13
13
|
/**
|
|
14
14
|
* Smart Server Component that handles locale detection and message loading automatically.
|
|
15
15
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/server/index.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/server/index.ts"],"mappings":";;;;;;;;AAuCA;iBAAgB,mBAAA,CAAoB,KAAA;AAAA,iBAId,WAAA,CACpB,MAAA,UACA,iBAAA,cAA4B,OAAA,CAAA,oBAAA;AAAA,iBA8Cd,YAAA,CACd,gBAAA,YACA,aAAA;;AAlDF;;iBA+DsB,YAAA,CAAA;EACpB;AAAA;EAEA,QAAA,EAAU,KAAA,CAAM,SAAA;AAAA,IACjB,OAAA,CAAA,KAAA,CAAA,wBAAA,CAAA,KAAA,CAAA,mBAAA,CAAA,gBAAA,GAAA,gBAAA;AAAA,iBAWqB,cAAA,CAAA,GAAc,OAAA;WAQlB,eAAA,EAAe,MAAA,GAAW,MAAA"}
|
package/dist/server/index.mjs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
"use server";
|
|
2
|
-
|
|
3
|
-
import { COOKIE_NAME, DEFAULT_LOCALE } from "../shared/constants.mjs";
|
|
4
1
|
import { formatMessage, getNestedMessage } from "../shared/utils.mjs";
|
|
5
2
|
import { I18nProvider as I18nProvider$1 } from "../client/index.mjs";
|
|
3
|
+
import { COOKIE_NAME, DEFAULT_LOCALE } from "../shared/constants.mjs";
|
|
6
4
|
import { discoverLocalePaths, getModuleLocalePaths } from "./module-loader.mjs";
|
|
7
5
|
import React from "react";
|
|
8
6
|
import fs from "node:fs/promises";
|
|
@@ -23,7 +21,7 @@ let registeredPaths = null;
|
|
|
23
21
|
* Register additional directories to search for locales.
|
|
24
22
|
* Can be called multiple times, but usually called once in RootLayout.
|
|
25
23
|
*/
|
|
26
|
-
|
|
24
|
+
function registerLocalePaths(paths) {
|
|
27
25
|
registeredPaths = Array.from(new Set([...registeredPaths || [], ...paths]));
|
|
28
26
|
}
|
|
29
27
|
async function getMessages(locale, searchDirectories) {
|
|
@@ -49,8 +47,8 @@ async function getMessages(locale, searchDirectories) {
|
|
|
49
47
|
}
|
|
50
48
|
return messages;
|
|
51
49
|
}
|
|
52
|
-
|
|
53
|
-
const headerList =
|
|
50
|
+
function detectLocale(supportedLocales, defaultLocale) {
|
|
51
|
+
const headerList = headers();
|
|
54
52
|
return match(new Negotiator({ headers: Object.fromEntries(headerList.entries()) }).languages(), supportedLocales, defaultLocale);
|
|
55
53
|
}
|
|
56
54
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["ClientProvider"],"sources":["../../src/server/index.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["ClientProvider"],"sources":["../../src/server/index.ts"],"sourcesContent":["import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { match } from \"@formatjs/intl-localematcher\";\nimport Negotiator from \"negotiator\";\nimport { cookies, headers } from \"next/headers\";\nimport React from \"react\";\nimport { I18nProvider as ClientProvider } from \"../client/index\";\nimport { COOKIE_NAME, DEFAULT_LOCALE } from \"../shared/constants\";\nimport { formatMessage, getNestedMessage } from \"../shared/utils\";\nimport type {\n AbstractIntlMessages,\n NestedKeyOf,\n TranslationKeys,\n} from \"../types\";\nimport { discoverLocalePaths } from \"./module-loader\";\n\nfunction deepMerge(target: any, source: any) {\n const result = { ...target };\n for (const key of Object.keys(source)) {\n if (\n source[key] instanceof Object &&\n key in target &&\n target[key] instanceof Object\n ) {\n result[key] = deepMerge(target[key], source[key]);\n } else {\n result[key] = source[key];\n }\n }\n return result;\n}\n\n// Internal state for locale paths\nlet registeredPaths: string[] | null = null;\n\n/**\n * Register additional directories to search for locales.\n * Can be called multiple times, but usually called once in RootLayout.\n */\nexport function registerLocalePaths(paths: string[]) {\n registeredPaths = Array.from(new Set([...(registeredPaths || []), ...paths]));\n}\n\nexport async function getMessages(\n locale: string,\n searchDirectories?: string[],\n) {\n // Auto-discovery if no paths registered\n if (registeredPaths === null || registeredPaths.length === 0) {\n const discovered = await discoverLocalePaths();\n registerLocalePaths(discovered);\n }\n\n let messages: AbstractIntlMessages = {};\n\n const defaultDir = path.join(process.cwd(), \"locales\");\n\n // Use provided paths, or registered paths, or just default\n const directoriesToScan = new Set<string>();\n\n if (registeredPaths) {\n for (const p of registeredPaths) directoriesToScan.add(p);\n }\n if (searchDirectories) {\n for (const p of searchDirectories) directoriesToScan.add(p);\n }\n directoriesToScan.add(defaultDir);\n\n for (const dir of Array.from(directoriesToScan)) {\n const localeDir = path.join(dir, locale);\n try {\n await fs.access(localeDir);\n const files = await fs.readdir(localeDir);\n\n for (const file of files) {\n if (file.endsWith(\".json\")) {\n const filePath = path.join(localeDir, file);\n const fileContent = await fs.readFile(filePath, \"utf-8\");\n const jsonContent = JSON.parse(fileContent);\n\n messages = deepMerge(messages, jsonContent);\n }\n }\n } catch (error) {\n // Ignore missing directories\n }\n }\n\n return messages;\n}\n\nexport function detectLocale(\n supportedLocales: string[],\n defaultLocale: string,\n) {\n const headerList = headers();\n const languages = new Negotiator({\n headers: Object.fromEntries((headerList as any).entries()),\n }).languages();\n\n return match(languages, supportedLocales, defaultLocale);\n}\n\n/**\n * Smart Server Component that handles locale detection and message loading automatically.\n */\nexport async function I18nProvider({\n children,\n}: {\n children: React.ReactNode;\n}) {\n const cookieStore = await cookies();\n const locale = cookieStore.get(COOKIE_NAME)?.value || DEFAULT_LOCALE;\n const messages = await getMessages(locale);\n\n // @ts-expect-error\n return React.createElement(ClientProvider, { locale, messages }, children);\n}\n\nexport * from \"./module-loader\";\n\nexport async function getTranslation() {\n const cookieStore = await cookies();\n const locale = cookieStore.get(COOKIE_NAME)?.value || DEFAULT_LOCALE;\n\n // If paths haven't been registered yet, we might be in a race condition.\n // In a real production app, we might want to have a deterministic way to load these.\n const messages = await getMessages(locale);\n\n const t = (key: TranslationKeys, values?: Record<string, any>) => {\n const message = getNestedMessage(messages, String(key));\n\n if (typeof message !== \"string\") {\n return String(key);\n }\n\n return formatMessage(message, values);\n };\n\n return { t, locale };\n}\n"],"mappings":";;;;;;;;;;;;AAgBA,SAAS,UAAU,QAAa,QAAa;CAC3C,MAAM,SAAS,EAAE,GAAG,QAAQ;AAC5B,MAAK,MAAM,OAAO,OAAO,KAAK,OAAO,CACnC,KACE,OAAO,gBAAgB,UACvB,OAAO,UACP,OAAO,gBAAgB,OAEvB,QAAO,OAAO,UAAU,OAAO,MAAM,OAAO,KAAK;KAEjD,QAAO,OAAO,OAAO;AAGzB,QAAO;;AAIT,IAAI,kBAAmC;;;;;AAMvC,SAAgB,oBAAoB,OAAiB;AACnD,mBAAkB,MAAM,KAAK,IAAI,IAAI,CAAC,GAAI,mBAAmB,EAAE,EAAG,GAAG,MAAM,CAAC,CAAC;;AAG/E,eAAsB,YACpB,QACA,mBACA;AAEA,KAAI,oBAAoB,QAAQ,gBAAgB,WAAW,EAEzD,qBADmB,MAAM,qBAAqB,CACf;CAGjC,IAAI,WAAiC,EAAE;CAEvC,MAAM,aAAa,KAAK,KAAK,QAAQ,KAAK,EAAE,UAAU;CAGtD,MAAM,oCAAoB,IAAI,KAAa;AAE3C,KAAI,gBACF,MAAK,MAAM,KAAK,gBAAiB,mBAAkB,IAAI,EAAE;AAE3D,KAAI,kBACF,MAAK,MAAM,KAAK,kBAAmB,mBAAkB,IAAI,EAAE;AAE7D,mBAAkB,IAAI,WAAW;AAEjC,MAAK,MAAM,OAAO,MAAM,KAAK,kBAAkB,EAAE;EAC/C,MAAM,YAAY,KAAK,KAAK,KAAK,OAAO;AACxC,MAAI;AACF,SAAM,GAAG,OAAO,UAAU;GAC1B,MAAM,QAAQ,MAAM,GAAG,QAAQ,UAAU;AAEzC,QAAK,MAAM,QAAQ,MACjB,KAAI,KAAK,SAAS,QAAQ,EAAE;IAC1B,MAAM,WAAW,KAAK,KAAK,WAAW,KAAK;IAC3C,MAAM,cAAc,MAAM,GAAG,SAAS,UAAU,QAAQ;IACxD,MAAM,cAAc,KAAK,MAAM,YAAY;AAE3C,eAAW,UAAU,UAAU,YAAY;;WAGxC,OAAO;;AAKlB,QAAO;;AAGT,SAAgB,aACd,kBACA,eACA;CACA,MAAM,aAAa,SAAS;AAK5B,QAAO,MAJW,IAAI,WAAW,EAC/B,SAAS,OAAO,YAAa,WAAmB,SAAS,CAAC,EAC3D,CAAC,CAAC,WAAW,EAEU,kBAAkB,cAAc;;;;;AAM1D,eAAsB,aAAa,EACjC,YAGC;CAED,MAAM,UADc,MAAM,SAAS,EACR,IAAI,YAAY,EAAE,SAAS;CACtD,MAAM,WAAW,MAAM,YAAY,OAAO;AAG1C,QAAO,MAAM,cAAcA,gBAAgB;EAAE;EAAQ;EAAU,EAAE,SAAS;;AAK5E,eAAsB,iBAAiB;CAErC,MAAM,UADc,MAAM,SAAS,EACR,IAAI,YAAY,EAAE,SAAS;CAItD,MAAM,WAAW,MAAM,YAAY,OAAO;CAE1C,MAAM,KAAK,KAAsB,WAAiC;EAChE,MAAM,UAAU,iBAAiB,UAAU,OAAO,IAAI,CAAC;AAEvD,MAAI,OAAO,YAAY,SACrB,QAAO,OAAO,IAAI;AAGpB,SAAO,cAAc,SAAS,OAAO;;AAGvC,QAAO;EAAE;EAAG;EAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-loader.d.cts","names":[],"sources":["../../src/server/module-loader.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"module-loader.d.cts","names":[],"sources":["../../src/server/module-loader.ts"],"mappings":";iBAIsB,mBAAA,CAAA,GAAuB,OAAA;;;;iBAgFvB,oBAAA,CACpB,cAAA,aACA,eAAA,YACC,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-loader.d.mts","names":[],"sources":["../../src/server/module-loader.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"module-loader.d.mts","names":[],"sources":["../../src/server/module-loader.ts"],"mappings":";;;iBAIsB,mBAAA,CAAA,GAAuB,OAAA;;AAA7C;;iBAgFsB,oBAAA,CACpB,cAAA,aACA,eAAA,YACC,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-loader.mjs","names":[],"sources":["../../src/server/module-loader.ts"],"sourcesContent":["import \"server-only\";\
|
|
1
|
+
{"version":3,"file":"module-loader.mjs","names":[],"sources":["../../src/server/module-loader.ts"],"sourcesContent":["import \"server-only\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\n\nexport async function discoverLocalePaths(): Promise<string[]> {\n const paths: string[] = [];\n const root = process.cwd();\n\n // Helper to find monorepo root (looking for pnpm-workspace.yaml or turbo.json)\n const findMonorepoRoot = async (current: string): Promise<string | null> => {\n const indicators = [\"pnpm-workspace.yaml\", \"package.json\"];\n let dir = current;\n\n console.log(\n `[intl]: Searching for monorepo root starting from: ${current}`,\n );\n\n while (dir !== path.parse(dir).root) {\n for (const indicator of indicators) {\n try {\n await fs.access(path.join(dir, indicator));\n // If we find pnpm-workspace.yaml, this is definitely it\n if (indicator === \"pnpm-workspace.yaml\") return dir;\n } catch {}\n }\n dir = path.dirname(dir);\n }\n return null;\n };\n\n const monorepoRoot = await findMonorepoRoot(root);\n\n // 1. Monorepo 'packages' scan\n if (monorepoRoot) {\n const packagesDir = path.join(monorepoRoot, \"packages\");\n try {\n const entries = await fs.readdir(packagesDir, { withFileTypes: true });\n for (const entry of entries) {\n if (entry.isDirectory()) {\n const localePath = path.join(packagesDir, entry.name, \"locales\");\n try {\n await fs.access(localePath);\n\n paths.push(localePath);\n } catch {}\n }\n }\n } catch (e) {}\n }\n\n // 2. node_modules/@arch-cadre scan (relative to app root)\n const nodeModulesKryo = path.join(root, \"node_modules\", \"@arch-cadre\");\n try {\n const entries = await fs.readdir(nodeModulesKryo, { withFileTypes: true });\n for (const entry of entries) {\n const localePath = path.join(nodeModulesKryo, entry.name, \"locales\");\n try {\n await fs.access(localePath);\n paths.push(localePath);\n } catch {}\n }\n } catch (e) {}\n\n // 3. Local 'modules' scan (relative to app root)\n const localModulesDir = path.join(root, \"modules\");\n try {\n const entries = await fs.readdir(localModulesDir, { withFileTypes: true });\n for (const entry of entries) {\n if (entry.isDirectory()) {\n const localePath = path.join(localModulesDir, entry.name, \"locales\");\n try {\n await fs.access(localePath);\n paths.push(localePath);\n } catch {}\n }\n }\n } catch (e) {}\n\n return Array.from(new Set(paths));\n}\n\n/**\n * Legacy support or manual overrides\n */\nexport async function getModuleLocalePaths(\n packageModules: string[] = [],\n localModulesDir: string = \"modules\",\n): Promise<string[]> {\n // ... rest of the existing function if we want to keep it,\n // but we'll probably favor discoverLocalePaths\n return discoverLocalePaths();\n}\n"],"mappings":";;;;;AAIA,eAAsB,sBAAyC;CAC7D,MAAM,QAAkB,EAAE;CAC1B,MAAM,OAAO,QAAQ,KAAK;CAG1B,MAAM,mBAAmB,OAAO,YAA4C;EAC1E,MAAM,aAAa,CAAC,uBAAuB,eAAe;EAC1D,IAAI,MAAM;AAEV,UAAQ,IACN,sDAAsD,UACvD;AAED,SAAO,QAAQ,KAAK,MAAM,IAAI,CAAC,MAAM;AACnC,QAAK,MAAM,aAAa,WACtB,KAAI;AACF,UAAM,GAAG,OAAO,KAAK,KAAK,KAAK,UAAU,CAAC;AAE1C,QAAI,cAAc,sBAAuB,QAAO;WAC1C;AAEV,SAAM,KAAK,QAAQ,IAAI;;AAEzB,SAAO;;CAGT,MAAM,eAAe,MAAM,iBAAiB,KAAK;AAGjD,KAAI,cAAc;EAChB,MAAM,cAAc,KAAK,KAAK,cAAc,WAAW;AACvD,MAAI;GACF,MAAM,UAAU,MAAM,GAAG,QAAQ,aAAa,EAAE,eAAe,MAAM,CAAC;AACtE,QAAK,MAAM,SAAS,QAClB,KAAI,MAAM,aAAa,EAAE;IACvB,MAAM,aAAa,KAAK,KAAK,aAAa,MAAM,MAAM,UAAU;AAChE,QAAI;AACF,WAAM,GAAG,OAAO,WAAW;AAE3B,WAAM,KAAK,WAAW;YAChB;;WAGL,GAAG;;CAId,MAAM,kBAAkB,KAAK,KAAK,MAAM,gBAAgB,cAAc;AACtE,KAAI;EACF,MAAM,UAAU,MAAM,GAAG,QAAQ,iBAAiB,EAAE,eAAe,MAAM,CAAC;AAC1E,OAAK,MAAM,SAAS,SAAS;GAC3B,MAAM,aAAa,KAAK,KAAK,iBAAiB,MAAM,MAAM,UAAU;AACpE,OAAI;AACF,UAAM,GAAG,OAAO,WAAW;AAC3B,UAAM,KAAK,WAAW;WAChB;;UAEH,GAAG;CAGZ,MAAM,kBAAkB,KAAK,KAAK,MAAM,UAAU;AAClD,KAAI;EACF,MAAM,UAAU,MAAM,GAAG,QAAQ,iBAAiB,EAAE,eAAe,MAAM,CAAC;AAC1E,OAAK,MAAM,SAAS,QAClB,KAAI,MAAM,aAAa,EAAE;GACvB,MAAM,aAAa,KAAK,KAAK,iBAAiB,MAAM,MAAM,UAAU;AACpE,OAAI;AACF,UAAM,GAAG,OAAO,WAAW;AAC3B,UAAM,KAAK,WAAW;WAChB;;UAGL,GAAG;AAEZ,QAAO,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC;;;;;AAMnC,eAAsB,qBACpB,iBAA2B,EAAE,EAC7B,kBAA0B,WACP;AAGnB,QAAO,qBAAqB"}
|
package/package.json
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arch-cadre/intl",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Core Intl for Kryo framework",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
|
-
"types": "./dist/index.d.mts",
|
|
9
8
|
"import": "./dist/index.mjs",
|
|
10
9
|
"require": "./dist/index.cjs"
|
|
11
10
|
},
|
|
12
11
|
"./client": {
|
|
13
|
-
"types": "./dist/client/index.d.mts",
|
|
14
12
|
"import": "./dist/client/index.mjs",
|
|
15
13
|
"require": "./dist/client/index.cjs"
|
|
16
14
|
},
|
|
17
15
|
"./server": {
|
|
18
|
-
"types": "./dist/server/index.d.mts",
|
|
19
16
|
"import": "./dist/server/index.mjs",
|
|
20
17
|
"require": "./dist/server/index.cjs"
|
|
21
18
|
},
|
|
@@ -51,7 +48,7 @@
|
|
|
51
48
|
"tsdown": "^0.20.3",
|
|
52
49
|
"typescript": "^5"
|
|
53
50
|
},
|
|
54
|
-
"types": "./dist/index.d.
|
|
51
|
+
"types": "./dist/index.d.cts",
|
|
55
52
|
"main": "./dist/index.cjs",
|
|
56
53
|
"module": "./dist/index.mjs"
|
|
57
54
|
}
|