@ubean/i18n 0.7.3 → 0.7.5

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/browser.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { c as localizePath, d as CompiledLocalePath, f as HonoLocalePath, g as LocaleRoutingConfig, h as I18nRoutingStrategy, i as localeFromSegment, l as switchLocalePath, n as extractLocaleFromPath, o as localeSegment, p as I18nLocaleMeta, r as getVueLocaleParam, s as localeSegments, t as compileLocalePaths, u as toVueRouterLocalePath } from "./paths-BDg85ZRp.js";
2
- import { a as parseLocaleCookie, i as detectLocaleFromAcceptLanguage, n as LocaleHeadTags, o as serializeLocaleCookie, r as buildLocaleHead, t as LocaleHeadInput } from "./head-wpqC86Oe.js";
1
+ import { c as localizePath, d as CompiledLocalePath, f as HonoLocalePath, g as LocaleRoutingConfig, h as I18nRoutingStrategy, i as localeFromSegment, l as switchLocalePath, n as extractLocaleFromPath, o as localeSegment, p as I18nLocaleMeta, r as getVueLocaleParam, s as localeSegments, t as compileLocalePaths, u as toVueRouterLocalePath } from "./paths-DC4damZ9.js";
2
+ import { a as parseLocaleCookie, i as detectLocaleFromAcceptLanguage, n as LocaleHeadTags, o as serializeLocaleCookie, r as buildLocaleHead, t as LocaleHeadInput } from "./head-CB93-M5F.js";
3
3
  export { type CompiledLocalePath, type HonoLocalePath, type I18nLocaleMeta, type I18nRoutingStrategy, type LocaleHeadInput, type LocaleHeadTags, type LocaleRoutingConfig, buildLocaleHead, compileLocalePaths, detectLocaleFromAcceptLanguage, extractLocaleFromPath, getVueLocaleParam, localeFromSegment, localeSegment, localeSegments, localizePath, parseLocaleCookie, serializeLocaleCookie, switchLocalePath, toVueRouterLocalePath };
package/dist/browser.js CHANGED
@@ -1,3 +1,3 @@
1
- import { a as extractLocaleFromPath, d as localizePath, f as switchLocalePath, i as compileLocalePaths, l as localeSegment, n as parseLocaleCookie, o as getVueLocaleParam, p as toVueRouterLocalePath, r as serializeLocaleCookie, s as localeFromSegment, t as detectLocaleFromAcceptLanguage, u as localeSegments } from "./detect-BOSXpF7l.js";
2
- import { t as buildLocaleHead } from "./head-x9R0hGV-.js";
1
+ import { a as extractLocaleFromPath, d as localizePath, f as switchLocalePath, i as compileLocalePaths, l as localeSegment, n as parseLocaleCookie, o as getVueLocaleParam, p as toVueRouterLocalePath, r as serializeLocaleCookie, s as localeFromSegment, t as detectLocaleFromAcceptLanguage, u as localeSegments } from "./detect-D8Y8wecr.js";
2
+ import { t as buildLocaleHead } from "./head-CHJYKWhe.js";
3
3
  export { buildLocaleHead, compileLocalePaths, detectLocaleFromAcceptLanguage, extractLocaleFromPath, getVueLocaleParam, localeFromSegment, localeSegment, localeSegments, localizePath, parseLocaleCookie, serializeLocaleCookie, switchLocalePath, toVueRouterLocalePath };
@@ -1,4 +1,4 @@
1
- //#region src/paths.ts
1
+ // src/paths.ts
2
2
  /** URL segment for a locale code (`paths` override, else the code itself). */
3
3
  function localeSegment(code, paths) {
4
4
  return paths?.[code] ?? code;
@@ -168,8 +168,7 @@ function compileLocalePaths(pagePath, cfg) {
168
168
  hono: honoPathsFor(pagePath, cfg)
169
169
  };
170
170
  }
171
- //#endregion
172
- //#region src/detect.ts
171
+ // src/detect.ts
173
172
  function detectLocaleFromAcceptLanguage(header, locales, fallback) {
174
173
  if (!header) return fallback;
175
174
  const requested = header.split(",").map((lang) => {
@@ -195,5 +194,4 @@ function parseLocaleCookie(cookieHeader, cookieName) {
195
194
  function serializeLocaleCookie(cookieName, locale) {
196
195
  return `${cookieName}=${encodeURIComponent(locale)}; Path=/; SameSite=Lax`;
197
196
  }
198
- //#endregion
199
197
  export { extractLocaleFromPath as a, localeRedirectTarget as c, localizePath as d, switchLocalePath as f, compileLocalePaths as i, localeSegment as l, parseLocaleCookie as n, getVueLocaleParam as o, toVueRouterLocalePath as p, serializeLocaleCookie as r, localeFromSegment as s, detectLocaleFromAcceptLanguage as t, localeSegments as u };
@@ -1,10 +1,7 @@
1
- import { g as LocaleRoutingConfig, p as I18nLocaleMeta } from "./paths-BDg85ZRp.js";
2
- //#region src/detect.d.ts
1
+ import { g as LocaleRoutingConfig, p as I18nLocaleMeta } from "./paths-DC4damZ9.js";
3
2
  declare function detectLocaleFromAcceptLanguage(header: string | undefined, locales: string[], fallback: string): string;
4
3
  declare function parseLocaleCookie(cookieHeader: string | undefined, cookieName: string): string | null;
5
4
  declare function serializeLocaleCookie(cookieName: string, locale: string): string;
6
- //#endregion
7
- //#region src/head.d.ts
8
5
  interface LocaleHeadInput {
9
6
  path: string;
10
7
  locale: string;
@@ -32,5 +29,4 @@ interface LocaleHeadTags {
32
29
  * `prefix_and_default` 下默认语言的 canonical 指向无前缀 URL,避免双 URL 重复收录。
33
30
  */
34
31
  declare function buildLocaleHead(input: LocaleHeadInput): LocaleHeadTags;
35
- //#endregion
36
32
  export { parseLocaleCookie as a, detectLocaleFromAcceptLanguage as i, LocaleHeadTags as n, serializeLocaleCookie as o, buildLocaleHead as r, LocaleHeadInput as t };
@@ -1,5 +1,5 @@
1
- import { a as extractLocaleFromPath, d as localizePath } from "./detect-BOSXpF7l.js";
2
- //#region src/head.ts
1
+ import { a as extractLocaleFromPath, d as localizePath } from "./detect-D8Y8wecr.js";
2
+ // src/head.ts
3
3
  function abs(baseUrl, path) {
4
4
  if (!baseUrl) return path;
5
5
  return `${baseUrl.replace(/\/+$/, "")}${path}`;
@@ -80,5 +80,4 @@ function buildLocaleHead(input) {
80
80
  meta
81
81
  };
82
82
  }
83
- //#endregion
84
83
  export { buildLocaleHead as t };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- import { a as localeRedirectTarget, c as localizePath, d as CompiledLocalePath, f as HonoLocalePath, g as LocaleRoutingConfig, h as I18nRoutingStrategy, i as localeFromSegment, l as switchLocalePath, m as I18nMiddlewareOptions, n as extractLocaleFromPath, o as localeSegment, p as I18nLocaleMeta, r as getVueLocaleParam, s as localeSegments, t as compileLocalePaths, u as toVueRouterLocalePath } from "./paths-BDg85ZRp.js";
2
- import { a as parseLocaleCookie, i as detectLocaleFromAcceptLanguage, n as LocaleHeadTags, o as serializeLocaleCookie, r as buildLocaleHead, t as LocaleHeadInput } from "./head-wpqC86Oe.js";
1
+ import { a as localeRedirectTarget, c as localizePath, d as CompiledLocalePath, f as HonoLocalePath, g as LocaleRoutingConfig, h as I18nRoutingStrategy, i as localeFromSegment, l as switchLocalePath, m as I18nMiddlewareOptions, n as extractLocaleFromPath, o as localeSegment, p as I18nLocaleMeta, r as getVueLocaleParam, s as localeSegments, t as compileLocalePaths, u as toVueRouterLocalePath } from "./paths-DC4damZ9.js";
2
+ import { a as parseLocaleCookie, i as detectLocaleFromAcceptLanguage, n as LocaleHeadTags, o as serializeLocaleCookie, r as buildLocaleHead, t as LocaleHeadInput } from "./head-CB93-M5F.js";
3
3
  import { createI18nMiddleware, getPathWithoutLocale, getRequestLocale as getRequestLocale$1 } from "./routing.js";
4
4
  import { LocaleMessage } from "@intlify/core";
5
- //#region src/context.d.ts
6
5
  type LocaleMessages = LocaleMessage;
7
6
  declare function createI18nCoreContext(locale: string, fallback: string, messages: Record<string, LocaleMessages>): import("@intlify/core").CoreContext<string, Record<string, LocaleMessages>, {}, {}, string | import("@intlify/core").LocaleDetector<any[]>, string, string>;
8
7
  type I18nCoreContext = ReturnType<typeof createI18nCoreContext>;
@@ -58,5 +57,4 @@ declare function getRequestLocale(): string;
58
57
  export declare function t(key: string, ...args: unknown[]): string;
59
58
  export declare function d(value: Date | number | string, ...args: unknown[]): string;
60
59
  export declare function n(value: number, ...args: unknown[]): string;
61
- //#endregion
62
60
  export { type CompiledLocalePath, type HonoLocalePath, type I18nCoreContext, type I18nLocaleMeta, type I18nMiddlewareOptions, type I18nRequestScope, type I18nRoutingStrategy, type LocaleHeadInput, type LocaleHeadTags, type LocaleMessages, type LocaleRoutingConfig, buildLocaleHead, compileLocalePaths, createI18nMiddleware, detectLocaleFromAcceptLanguage, extractLocaleFromPath, getRequestLocale as getAlsLocale, getPathWithoutLocale, getRequestLocale$1 as getRequestLocale, getVueLocaleParam, localeFromSegment, localeRedirectTarget, localeSegment, localeSegments, localizePath, parseLocaleCookie, serializeLocaleCookie, switchLocalePath, toVueRouterLocalePath };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as extractLocaleFromPath, c as localeRedirectTarget, d as localizePath, f as switchLocalePath, i as compileLocalePaths, l as localeSegment, n as parseLocaleCookie, o as getVueLocaleParam, p as toVueRouterLocalePath, r as serializeLocaleCookie, s as localeFromSegment, t as detectLocaleFromAcceptLanguage, u as localeSegments } from "./detect-BOSXpF7l.js";
2
- import { C as t, S as setLocaleMeta, _ as n, a as d, b as setFallbackLocale, c as getI18nScope, d as getLocaleMeta, f as getLocaleName, g as mergeLocaleMessages, h as listLocaleCodes, i as createRequestContext, l as getLocaleDir, m as getRequestLocale, n as getPathWithoutLocale, o as ensureLocaleMessages, p as getRegisteredLocalesMeta, r as getRequestLocale$1, s as getFallbackLocale, t as createI18nMiddleware, u as getLocaleMessages, v as registerLocaleLoader, x as setLocaleMessages, y as runWithI18n } from "./routing-AUeKju4d.js";
3
- import { t as buildLocaleHead } from "./head-x9R0hGV-.js";
1
+ import { a as extractLocaleFromPath, c as localeRedirectTarget, d as localizePath, f as switchLocalePath, i as compileLocalePaths, l as localeSegment, n as parseLocaleCookie, o as getVueLocaleParam, p as toVueRouterLocalePath, r as serializeLocaleCookie, s as localeFromSegment, t as detectLocaleFromAcceptLanguage, u as localeSegments } from "./detect-D8Y8wecr.js";
2
+ import { C as t, S as setLocaleMeta, _ as n, a as d, b as setFallbackLocale, c as getI18nScope, d as getLocaleMeta, f as getLocaleName, g as mergeLocaleMessages, h as listLocaleCodes, i as createRequestContext, l as getLocaleDir, m as getRequestLocale, n as getPathWithoutLocale, o as ensureLocaleMessages, p as getRegisteredLocalesMeta, r as getRequestLocale$1, s as getFallbackLocale, t as createI18nMiddleware, u as getLocaleMessages, v as registerLocaleLoader, x as setLocaleMessages, y as runWithI18n } from "./routing-DpIJljHL.js";
3
+ import { t as buildLocaleHead } from "./head-CHJYKWhe.js";
4
4
  export { buildLocaleHead, compileLocalePaths, createI18nMiddleware, createRequestContext, d, detectLocaleFromAcceptLanguage, ensureLocaleMessages, extractLocaleFromPath, getRequestLocale as getAlsLocale, getFallbackLocale, getI18nScope, getLocaleDir, getLocaleMessages, getLocaleMeta, getLocaleName, getPathWithoutLocale, getRegisteredLocalesMeta, getRequestLocale$1 as getRequestLocale, getVueLocaleParam, listLocaleCodes, localeFromSegment, localeRedirectTarget, localeSegment, localeSegments, localizePath, mergeLocaleMessages, n, parseLocaleCookie, registerLocaleLoader, runWithI18n, serializeLocaleCookie, setFallbackLocale, setLocaleMessages, setLocaleMeta, switchLocalePath, t, toVueRouterLocalePath };
@@ -1,4 +1,3 @@
1
- //#region src/types.d.ts
2
1
  type I18nRoutingStrategy = 'prefix' | 'prefix_except_default' | 'prefix_and_default' | 'no_prefix';
3
2
  interface LocaleRoutingConfig {
4
3
  defaultLocale: string;
@@ -48,8 +47,6 @@ interface I18nLocaleMeta {
48
47
  dir?: 'ltr' | 'rtl';
49
48
  isDefault?: boolean;
50
49
  }
51
- //#endregion
52
- //#region src/paths.d.ts
53
50
  /** URL segment for a locale code (`paths` override, else the code itself). */
54
51
  declare function localeSegment(code: string, paths?: Record<string, string>): string;
55
52
  /**
@@ -105,5 +102,4 @@ declare function extractLocaleFromPath(path: string, localeCodes: string[], path
105
102
  declare function localizePath(path: string, locale: string, cfg: LocaleRoutingConfig): string;
106
103
  declare function switchLocalePath(locale: string, currentPath: string, cfg: LocaleRoutingConfig): string;
107
104
  declare function compileLocalePaths(pagePath: string, cfg: LocaleRoutingConfig): CompiledLocalePath;
108
- //#endregion
109
105
  export { localeRedirectTarget as a, localizePath as c, CompiledLocalePath as d, HonoLocalePath as f, LocaleRoutingConfig as g, I18nRoutingStrategy as h, localeFromSegment as i, switchLocalePath as l, I18nMiddlewareOptions as m, extractLocaleFromPath as n, localeSegment as o, I18nLocaleMeta as p, getVueLocaleParam as r, localeSegments as s, compileLocalePaths as t, toVueRouterLocalePath as u };
@@ -1,7 +1,7 @@
1
- import { a as extractLocaleFromPath, d as localizePath, n as parseLocaleCookie, r as serializeLocaleCookie, t as detectLocaleFromAcceptLanguage } from "./detect-BOSXpF7l.js";
1
+ import { a as extractLocaleFromPath, d as localizePath, n as parseLocaleCookie, r as serializeLocaleCookie, t as detectLocaleFromAcceptLanguage } from "./detect-D8Y8wecr.js";
2
2
  import { AsyncLocalStorage } from "node:async_hooks";
3
3
  import { createCoreContext, datetime, number, translate } from "@intlify/core";
4
- //#region src/context.ts
4
+ // src/context.ts
5
5
  /**
6
6
  * Request-scoped i18n engine (@intlify/core).
7
7
  *
@@ -208,8 +208,7 @@ function deepMerge(target, source) {
208
208
  }
209
209
  return result;
210
210
  }
211
- //#endregion
212
- //#region src/routing.ts
211
+ // src/routing.ts
213
212
  const DETECT_DEFAULTS = {
214
213
  cookieName: "ubean_locale",
215
214
  redirectOn: "root",
@@ -327,5 +326,4 @@ function getRequestLocale(c) {
327
326
  function getPathWithoutLocale(c) {
328
327
  return c.get("pathWithoutLocale") || new URL(c.req.url).pathname;
329
328
  }
330
- //#endregion
331
329
  export { t as C, setLocaleMeta as S, n as _, d as a, setFallbackLocale as b, getI18nScope as c, getLocaleMeta as d, getLocaleName as f, mergeLocaleMessages as g, listLocaleCodes as h, createRequestContext as i, getLocaleDir as l, getRequestLocale$1 as m, getPathWithoutLocale as n, ensureLocaleMessages as o, getRegisteredLocalesMeta as p, getRequestLocale as r, getFallbackLocale as s, createI18nMiddleware as t, getLocaleMessages as u, registerLocaleLoader as v, setLocaleMessages as x, runWithI18n as y };
package/dist/routing.d.ts CHANGED
@@ -1,9 +1,7 @@
1
- import { c as localizePath, h as I18nRoutingStrategy, l as switchLocalePath, m as I18nMiddlewareOptions, n as extractLocaleFromPath, t as compileLocalePaths } from "./paths-BDg85ZRp.js";
1
+ import { c as localizePath, h as I18nRoutingStrategy, l as switchLocalePath, m as I18nMiddlewareOptions, n as extractLocaleFromPath, t as compileLocalePaths } from "./paths-DC4damZ9.js";
2
2
  import { UbeanEnv } from "@ubean/shared";
3
3
  import { Context, MiddlewareHandler } from "hono";
4
- //#region src/routing.d.ts
5
4
  export declare function createI18nMiddleware(options: I18nMiddlewareOptions): MiddlewareHandler<UbeanEnv>;
6
5
  export declare function getRequestLocale(c: Context): string;
7
6
  export declare function getPathWithoutLocale(c: Context): string;
8
- //#endregion
9
7
  export { type I18nMiddlewareOptions, type I18nRoutingStrategy, compileLocalePaths, extractLocaleFromPath, localizePath, switchLocalePath };
package/dist/routing.js CHANGED
@@ -1,3 +1,3 @@
1
- import { a as extractLocaleFromPath, d as localizePath, f as switchLocalePath, i as compileLocalePaths } from "./detect-BOSXpF7l.js";
2
- import { n as getPathWithoutLocale, r as getRequestLocale, t as createI18nMiddleware } from "./routing-AUeKju4d.js";
1
+ import { a as extractLocaleFromPath, d as localizePath, f as switchLocalePath, i as compileLocalePaths } from "./detect-D8Y8wecr.js";
2
+ import { n as getPathWithoutLocale, r as getRequestLocale, t as createI18nMiddleware } from "./routing-DpIJljHL.js";
3
3
  export { compileLocalePaths, createI18nMiddleware, extractLocaleFromPath, getPathWithoutLocale, getRequestLocale, localizePath, switchLocalePath };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ubean/i18n",
3
- "version": "0.7.3",
3
+ "version": "0.7.5",
4
4
  "description": "i18n for ubean (vue-i18n / @intlify/core, compact locale routing, ALS)",
5
5
  "files": [
6
6
  "dist"
@@ -25,13 +25,13 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@intlify/core": "11.4.16",
28
- "@ubean/shared": "0.7.3",
28
+ "@ubean/shared": "0.7.5",
29
29
  "hono": "4.13.13"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/node": "^26.6.5",
33
33
  "typescript": "npm:typescript-native-bridge@latest",
34
- "vite-plus": "1.3.0"
34
+ "vite-plus": "1.4.0"
35
35
  },
36
36
  "engines": {
37
37
  "node": ">=22"