@barqel/barq-i18n 0.0.0-stage → 1.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.
@@ -0,0 +1,8 @@
1
+ import type { App } from "@barqel/barq";
2
+ import type { I18nOptions } from "./types";
3
+ export * from "./middleware";
4
+ export * from "./negotiator";
5
+ export * from "./translator";
6
+ export * from "./types";
7
+ export declare function i18nPlugin(options: I18nOptions): (app: App<any>) => void;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AAExB,wBAAgB,UAAU,CAAC,OAAO,EAAE,WAAW,IAEtC,KAAK,GAAG,CAAC,GAAG,CAAC,UAGrB"}
package/dist/index.js ADDED
@@ -0,0 +1,136 @@
1
+ // src/negotiator.ts
2
+ function negotiateLocale(acceptLanguageHeader, supportedLocales, defaultLocale) {
3
+ if (!acceptLanguageHeader)
4
+ return defaultLocale;
5
+ const candidates = [];
6
+ const parts = acceptLanguageHeader.split(",");
7
+ for (const part of parts) {
8
+ const [rawLocale, rawQ] = part.trim().split(";");
9
+ const locale = rawLocale?.trim().toLowerCase();
10
+ if (!locale)
11
+ continue;
12
+ let q = 1;
13
+ if (rawQ) {
14
+ const match = /q=([0-9.]+)/i.exec(rawQ);
15
+ if (match?.[1]) {
16
+ const parsed = Number.parseFloat(match[1]);
17
+ if (!Number.isNaN(parsed))
18
+ q = parsed;
19
+ }
20
+ }
21
+ candidates.push({ locale, q });
22
+ }
23
+ candidates.sort((a, b) => b.q - a.q);
24
+ const normalizedSupported = supportedLocales.map((l) => l.toLowerCase());
25
+ for (const candidate of candidates) {
26
+ if (candidate.q === 0)
27
+ continue;
28
+ const directIdx = normalizedSupported.indexOf(candidate.locale);
29
+ if (directIdx !== -1) {
30
+ return supportedLocales[directIdx];
31
+ }
32
+ const baseCode = candidate.locale.split("-")[0];
33
+ if (baseCode) {
34
+ const baseIdx = normalizedSupported.findIndex((l) => l.startsWith(baseCode));
35
+ if (baseIdx !== -1) {
36
+ return supportedLocales[baseIdx];
37
+ }
38
+ }
39
+ }
40
+ return defaultLocale;
41
+ }
42
+
43
+ // src/translator.ts
44
+ function resolveNestedKey(obj, path) {
45
+ const parts = path.split(".");
46
+ let current = obj;
47
+ for (const part of parts) {
48
+ if (current === null || typeof current !== "object")
49
+ return null;
50
+ current = current[part];
51
+ }
52
+ return typeof current === "string" ? current : null;
53
+ }
54
+ function interpolate(template, params) {
55
+ if (!params)
56
+ return template;
57
+ return template.replace(/\{(\w+)\}/g, (_, key) => {
58
+ return key in params ? String(params[key]) : `{${key}}`;
59
+ });
60
+ }
61
+ function createTranslator(translations, currentLocale, defaultLocale) {
62
+ const currentDict = translations[currentLocale] ?? translations[currentLocale.toLowerCase()] ?? {};
63
+ const defaultDict = translations[defaultLocale] ?? translations[defaultLocale.toLowerCase()] ?? {};
64
+ return (key, params) => {
65
+ const raw = resolveNestedKey(currentDict, key) ?? resolveNestedKey(defaultDict, key);
66
+ if (raw === null) {
67
+ return key;
68
+ }
69
+ return interpolate(raw, params);
70
+ };
71
+ }
72
+
73
+ // src/middleware.ts
74
+ function i18nMiddleware(options) {
75
+ const queryParam = options.queryParam ?? "lang";
76
+ const headerName = options.headerName?.toLowerCase() ?? "accept-language";
77
+ const cookieName = options.cookieName;
78
+ return {
79
+ async before(ctx) {
80
+ let locale = null;
81
+ if (options.extractor) {
82
+ locale = await options.extractor(ctx);
83
+ }
84
+ if (!locale && queryParam) {
85
+ const fromQuery = ctx.queryParam(queryParam);
86
+ if (fromQuery && options.locales.includes(fromQuery)) {
87
+ locale = fromQuery;
88
+ }
89
+ }
90
+ if (!locale && cookieName) {
91
+ const fromCookie = ctx.cookies.get(cookieName);
92
+ if (fromCookie && options.locales.includes(fromCookie)) {
93
+ locale = fromCookie;
94
+ }
95
+ }
96
+ if (!locale) {
97
+ const acceptHeader = ctx.req.headers.get(headerName);
98
+ locale = negotiateLocale(acceptHeader, options.locales, options.defaultLocale);
99
+ }
100
+ const t = createTranslator(options.translations, locale, options.defaultLocale);
101
+ const state = ctx.state;
102
+ state.locale = locale;
103
+ state.t = t;
104
+ ctx.t = t;
105
+ },
106
+ after(ctx, res) {
107
+ const locale = ctx.state.locale;
108
+ if (locale && !res.headers.has("content-language")) {
109
+ const headers = new Headers(res.headers);
110
+ headers.set("content-language", locale);
111
+ return new Response(res.body, {
112
+ status: res.status,
113
+ statusText: res.statusText,
114
+ headers
115
+ });
116
+ }
117
+ return res;
118
+ }
119
+ };
120
+ }
121
+
122
+ // src/index.ts
123
+ function i18nPlugin(options) {
124
+ const mw = i18nMiddleware(options);
125
+ return (app) => {
126
+ app.use(mw);
127
+ };
128
+ }
129
+ export {
130
+ createTranslator,
131
+ i18nMiddleware,
132
+ i18nPlugin,
133
+ negotiateLocale
134
+ };
135
+
136
+ //# debugId=83A3F1691CBF2EEE64756E2164756E21
@@ -0,0 +1,13 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/negotiator.ts", "../src/translator.ts", "../src/middleware.ts", "../src/index.ts"],
4
+ "sourcesContent": [
5
+ "interface QualityLocale {\n\tlocale: string;\n\tq: number;\n}\n\nexport function negotiateLocale(\n\tacceptLanguageHeader: string | null,\n\tsupportedLocales: string[],\n\tdefaultLocale: string,\n): string {\n\tif (!acceptLanguageHeader) return defaultLocale;\n\n\tconst candidates: QualityLocale[] = [];\n\tconst parts = acceptLanguageHeader.split(\",\");\n\n\tfor (const part of parts) {\n\t\tconst [rawLocale, rawQ] = part.trim().split(\";\");\n\t\tconst locale = rawLocale?.trim().toLowerCase();\n\t\tif (!locale) continue;\n\n\t\tlet q = 1;\n\t\tif (rawQ) {\n\t\t\tconst match = /q=([0-9.]+)/i.exec(rawQ);\n\t\t\tif (match?.[1]) {\n\t\t\t\tconst parsed = Number.parseFloat(match[1]);\n\t\t\t\tif (!Number.isNaN(parsed)) q = parsed;\n\t\t\t}\n\t\t}\n\n\t\tcandidates.push({ locale, q });\n\t}\n\n\tcandidates.sort((a, b) => b.q - a.q);\n\n\tconst normalizedSupported = supportedLocales.map((l) => l.toLowerCase());\n\n\tfor (const candidate of candidates) {\n\t\tif (candidate.q === 0) continue;\n\n\t\tconst directIdx = normalizedSupported.indexOf(candidate.locale);\n\t\tif (directIdx !== -1) {\n\t\t\treturn supportedLocales[directIdx]!;\n\t\t}\n\n\t\tconst baseCode = candidate.locale.split(\"-\")[0];\n\t\tif (baseCode) {\n\t\t\tconst baseIdx = normalizedSupported.findIndex((l) =>\n\t\t\t\tl.startsWith(baseCode),\n\t\t\t);\n\t\t\tif (baseIdx !== -1) {\n\t\t\t\treturn supportedLocales[baseIdx]!;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn defaultLocale;\n}\n",
6
+ "import type { TranslationDictionary, TranslationsRecord } from \"./types\";\n\nfunction resolveNestedKey(\n\tobj: TranslationDictionary,\n\tpath: string,\n): string | null {\n\tconst parts = path.split(\".\");\n\tlet current: any = obj;\n\n\tfor (const part of parts) {\n\t\tif (current === null || typeof current !== \"object\") return null;\n\t\tcurrent = current[part];\n\t}\n\n\treturn typeof current === \"string\" ? current : null;\n}\n\nfunction interpolate(\n\ttemplate: string,\n\tparams?: Record<string, string | number>,\n): string {\n\tif (!params) return template;\n\treturn template.replace(/\\{(\\w+)\\}/g, (_, key) => {\n\t\treturn key in params ? String(params[key]) : `{${key}}`;\n\t});\n}\n\nexport function createTranslator(\n\ttranslations: TranslationsRecord,\n\tcurrentLocale: string,\n\tdefaultLocale: string,\n) {\n\tconst currentDict =\n\t\ttranslations[currentLocale] ??\n\t\ttranslations[currentLocale.toLowerCase()] ??\n\t\t{};\n\tconst defaultDict =\n\t\ttranslations[defaultLocale] ??\n\t\ttranslations[defaultLocale.toLowerCase()] ??\n\t\t{};\n\n\treturn (key: string, params?: Record<string, string | number>): string => {\n\t\tconst raw =\n\t\t\tresolveNestedKey(currentDict, key) ?? resolveNestedKey(defaultDict, key);\n\t\tif (raw === null) {\n\t\t\treturn key;\n\t\t}\n\t\treturn interpolate(raw, params);\n\t};\n}\n",
7
+ "import type { Context, Middleware } from \"@barqel/barq\";\nimport { negotiateLocale } from \"./negotiator\";\nimport { createTranslator } from \"./translator\";\nimport type { I18nOptions, TranslateFunction } from \"./types\";\n\nexport function i18nMiddleware(options: I18nOptions): Middleware {\n\tconst queryParam = options.queryParam ?? \"lang\";\n\tconst headerName = options.headerName?.toLowerCase() ?? \"accept-language\";\n\tconst cookieName = options.cookieName;\n\n\treturn {\n\t\tasync before(ctx: Context) {\n\t\t\tlet locale: string | null = null;\n\n\t\t\tif (options.extractor) {\n\t\t\t\tlocale = await options.extractor(ctx);\n\t\t\t}\n\n\t\t\tif (!locale && queryParam) {\n\t\t\t\tconst fromQuery = ctx.queryParam(queryParam);\n\t\t\t\tif (fromQuery && options.locales.includes(fromQuery)) {\n\t\t\t\t\tlocale = fromQuery;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!locale && cookieName) {\n\t\t\t\tconst fromCookie = ctx.cookies.get(cookieName);\n\t\t\t\tif (fromCookie && options.locales.includes(fromCookie)) {\n\t\t\t\t\tlocale = fromCookie;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!locale) {\n\t\t\t\tconst acceptHeader = ctx.req.headers.get(headerName);\n\t\t\t\tlocale = negotiateLocale(\n\t\t\t\t\tacceptHeader,\n\t\t\t\t\toptions.locales,\n\t\t\t\t\toptions.defaultLocale,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst t: TranslateFunction = createTranslator(\n\t\t\t\toptions.translations,\n\t\t\t\tlocale,\n\t\t\t\toptions.defaultLocale,\n\t\t\t);\n\n\t\t\tconst state = ctx.state as Record<string, unknown>;\n\t\t\tstate.locale = locale;\n\t\t\tstate.t = t;\n\t\t\t(ctx as any).t = t;\n\t\t},\n\n\t\tafter(ctx: Context, res: Response) {\n\t\t\tconst locale = (ctx.state as Record<string, unknown>).locale as\n\t\t\t\t| string\n\t\t\t\t| undefined;\n\t\t\tif (locale && !res.headers.has(\"content-language\")) {\n\t\t\t\tconst headers = new Headers(res.headers);\n\t\t\t\theaders.set(\"content-language\", locale);\n\t\t\t\treturn new Response(res.body, {\n\t\t\t\t\tstatus: res.status,\n\t\t\t\t\tstatusText: res.statusText,\n\t\t\t\t\theaders,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn res;\n\t\t},\n\t};\n}\n",
8
+ "import type { App } from \"@barqel/barq\";\nimport { i18nMiddleware } from \"./middleware\";\nimport type { I18nOptions } from \"./types\";\n\nexport * from \"./middleware\";\nexport * from \"./negotiator\";\nexport * from \"./translator\";\nexport * from \"./types\";\n\nexport function i18nPlugin(options: I18nOptions) {\n\tconst mw = i18nMiddleware(options);\n\treturn (app: App<any>) => {\n\t\tapp.use(mw);\n\t};\n}\n"
9
+ ],
10
+ "mappings": ";AAKO,SAAS,eAAe,CAC9B,sBACA,kBACA,eACS;AAAA,EACT,IAAI,CAAC;AAAA,IAAsB,OAAO;AAAA,EAElC,MAAM,aAA8B,CAAC;AAAA,EACrC,MAAM,QAAQ,qBAAqB,MAAM,GAAG;AAAA,EAE5C,WAAW,QAAQ,OAAO;AAAA,IACzB,OAAO,WAAW,QAAQ,KAAK,KAAK,EAAE,MAAM,GAAG;AAAA,IAC/C,MAAM,SAAS,WAAW,KAAK,EAAE,YAAY;AAAA,IAC7C,IAAI,CAAC;AAAA,MAAQ;AAAA,IAEb,IAAI,IAAI;AAAA,IACR,IAAI,MAAM;AAAA,MACT,MAAM,QAAQ,eAAe,KAAK,IAAI;AAAA,MACtC,IAAI,QAAQ,IAAI;AAAA,QACf,MAAM,SAAS,O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AQ,aACT;AAAA,MACD;AAAA,MAEA,MAAM,IAAuB,iBAC5B,QAAQ,cACR,QACA,QAAQ,aACT;AAAA,MAEA,MAAM,QAAQ,IAAI;AAAA,MAClB,MAAM,SAAS;AAAA,MACf,MAAM,IAAI;AAAA,MACT,IAAY,IAAI;AAAA;AAAA,IAGlB,KAAK,CAAC,KAAc,KAAe;AAAA,MAClC,MAAM,SAAU,IAAI,MAAkC;AAAA,MAGtD,IAAI,UAAU,CAAC,IAAI,QAAQ,IAAI,kBAAkB,GAAG;AAAA,QACnD,MAAM,UAAU,IAAI,QAAQ,IAAI,OAAO;AAAA,QACvC,QAAQ,IAAI,oBAAoB,MAAM;AAAA,QACtC,OAAO,IAAI,SAAS,IAAI,MAAM;AAAA,UAC7B,QAAQ,IAAI;AAAA,UACZ,YAAY,IAAI;AAAA,UAChB;AAAA,QACD,CAAC;AAAA,MACF;AAAA,MACA,OAAO;AAAA;AAAA,EAET;AAAA;;;AC3DM,SAAS,UAAU,CAAC,SAAsB;AAAA,EAChD,MAAM,KAAK,eAAe,OAAO;AAAA,EACjC,OAAO,CAAC,QAAkB;AAAA,IACzB,IAAI,IAAI,EAAE;AAAA;AAAA;",
11
+ "debugId": "83A3F1691CBF2EEE64756E2164756E21",
12
+ "names": []
13
+ }
@@ -0,0 +1,4 @@
1
+ import type { Middleware } from "@barqel/barq";
2
+ import type { I18nOptions } from "./types";
3
+ export declare function i18nMiddleware(options: I18nOptions): Middleware;
4
+ //# sourceMappingURL=middleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,UAAU,EAAE,MAAM,cAAc,CAAC;AAGxD,OAAO,KAAK,EAAE,WAAW,EAAqB,MAAM,SAAS,CAAC;AAE9D,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,GAAG,UAAU,CAgE/D"}
@@ -0,0 +1,2 @@
1
+ export declare function negotiateLocale(acceptLanguageHeader: string | null, supportedLocales: string[], defaultLocale: string): string;
2
+ //# sourceMappingURL=negotiator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"negotiator.d.ts","sourceRoot":"","sources":["../src/negotiator.ts"],"names":[],"mappings":"AAKA,wBAAgB,eAAe,CAC9B,oBAAoB,EAAE,MAAM,GAAG,IAAI,EACnC,gBAAgB,EAAE,MAAM,EAAE,EAC1B,aAAa,EAAE,MAAM,GACnB,MAAM,CA+CR"}
@@ -0,0 +1,3 @@
1
+ import type { TranslationsRecord } from "./types";
2
+ export declare function createTranslator(translations: TranslationsRecord, currentLocale: string, defaultLocale: string): (key: string, params?: Record<string, string | number>) => string;
3
+ //# sourceMappingURL=translator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translator.d.ts","sourceRoot":"","sources":["../src/translator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,kBAAkB,EAAE,MAAM,SAAS,CAAC;AA2BzE,wBAAgB,gBAAgB,CAC/B,YAAY,EAAE,kBAAkB,EAChC,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,IAWb,KAAK,MAAM,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,KAAG,MAAM,CAQtE"}
@@ -0,0 +1,16 @@
1
+ import type { Context } from "@barqel/barq";
2
+ export type TranslationDictionary = {
3
+ [key: string]: string | TranslationDictionary;
4
+ };
5
+ export type TranslationsRecord = Record<string, TranslationDictionary>;
6
+ export interface I18nOptions {
7
+ defaultLocale: string;
8
+ locales: string[];
9
+ translations: TranslationsRecord;
10
+ queryParam?: string;
11
+ headerName?: string;
12
+ cookieName?: string;
13
+ extractor?: (ctx: Context) => string | null | Promise<string | null>;
14
+ }
15
+ export type TranslateFunction = (key: string, params?: Record<string, string | number>) => string;
16
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,MAAM,qBAAqB,GAAG;IACnC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,qBAAqB,CAAC;CAC9C,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;AAEvE,MAAM,WAAW,WAAW;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,EAAE,kBAAkB,CAAC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CACrE;AAED,MAAM,MAAM,iBAAiB,GAAG,CAC/B,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,KACpC,MAAM,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,37 @@
1
1
  {
2
- "name": "@barqel/barq-i18n",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "@barqel/barq-i18n",
3
+ "version": "1.0.0",
4
+ "description": "Zero-dependency, high-performance API internationalization and translation plugin for Barq",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "scripts": {
18
+ "format": "biome format --write .",
19
+ "lint": "biome lint .",
20
+ "check": "biome check .",
21
+ "build": "rm -rf dist && bun build src/index.ts --external @barqel/barq --target=node --format=esm --sourcemap=external --outdir dist && tsc --emitDeclarationOnly --declaration --outDir dist",
22
+ "test": "bun test",
23
+ "prepublishOnly": "bun run check && bun test && bun run build"
24
+ },
25
+ "files": [
26
+ "dist"
27
+ ],
28
+ "peerDependencies": {
29
+ "@barqel/barq": ">=1.0.0"
30
+ },
31
+ "devDependencies": {
32
+ "@biomejs/biome": "^2.5.15",
33
+ "@types/bun": "^1.2.0",
34
+ "@types/node": "^20.0.0",
35
+ "typescript": "^5.0.0"
36
+ }
37
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.