@zerotal/i18n 1.6.3 → 1.7.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.
Files changed (2) hide show
  1. package/api-surface.md +100 -0
  2. package/package.json +3 -2
package/api-surface.md ADDED
@@ -0,0 +1,100 @@
1
+ # @zerotal/i18n — public API surface
2
+
3
+ <!-- AUTO-GENERATED by scripts/api-surface.ts. Do not edit by hand.
4
+ Run `bun run api:surface` to regenerate after an intentional API change. -->
5
+
6
+ ## . `(./src/index.ts)`
7
+
8
+ class CatalogLoadError = {
9
+ new (file: string, cause: unknown): CatalogLoadError
10
+ readonly code: string
11
+ readonly context?: Record<string, unknown> | undefined
12
+ readonly status: number
13
+ }
14
+
15
+ class I18nContext = {
16
+ new (): I18nContext
17
+ static current: () => string | undefined
18
+ static run: <T>(locale: string, callback: () => T) => T
19
+ }
20
+
21
+ class I18nError = {
22
+ new (message: string, code?: string, status?: number, context?: Record<string, unknown>): I18nError
23
+ readonly code: string
24
+ readonly context?: Record<string, unknown> | undefined
25
+ readonly status: number
26
+ }
27
+
28
+ class I18nProvider = {
29
+ new (app: Application): I18nProvider
30
+ static dependsOn?: (new (app: Application) => ServiceProvider)[]
31
+ static environments: AppEnvironment[]
32
+ static priority?: number
33
+ static provides: readonly ['i18n']
34
+ devProcesses: () => DevProcessDefinition[]
35
+ doctorChecks: () => DoctorCheck[]
36
+ onBooted: () => Promise<void>
37
+ onBooting: () => Promise<void>
38
+ onRegister: () => void
39
+ onRequestProcessed: (_ctx: HttpContext) => Promise<void>
40
+ onRequestReceived: (_ctx: HttpContext) => Promise<void>
41
+ onResponseSent: (_ctx: HttpContext) => Promise<void>
42
+ onStarted: () => Promise<void>
43
+ onStarting: () => Promise<void>
44
+ onStopped: () => Promise<void>
45
+ onStopping: () => Promise<void>
46
+ replContext: () => Record<string, unknown>
47
+ }
48
+
49
+ class LocaleMiddleware = {
50
+ new (): LocaleMiddleware
51
+ static configure: (translator: Translator, config: I18nConfigShape) => void
52
+ handle: (http: HttpContext, next: NextFn) => Promise<Response | void>
53
+ }
54
+
55
+ class Translator = {
56
+ new (opts: TranslatorOptions): Translator
57
+ addCatalog: (locale: string, messages: Messages) => void
58
+ has: (key: string, locale?: string) => boolean
59
+ locales: string[]
60
+ readonly defaultLocale: string
61
+ readonly fallbackLocale: string
62
+ translate: (key: string, replacements?: Replacements, locale?: string) => string
63
+ }
64
+
65
+ const Lang = Translator
66
+
67
+ function I18nConfig = (options?: Partial<I18nConfigShape>) => I18nConfigShape
68
+
69
+ function loadCatalogs = (dir: string) => Promise<Catalogs>
70
+
71
+ function parseAcceptLanguage = (header: string | null) => string[]
72
+
73
+ function resolveLocale = (request: Request, config: I18nConfigShape) => string
74
+
75
+ function t = (key: string, replacements?: Replacements, locale?: string) => string
76
+
77
+ interface I18nConfigShape = {
78
+ catalogs?: Catalogs
79
+ cookieKey: string
80
+ defaultLocale: string
81
+ fallbackLocale: string
82
+ loadPath?: string
83
+ queryKey: string
84
+ resolvers: LocaleResolver[]
85
+ supportedLocales: string[]
86
+ }
87
+
88
+ interface TranslatorOptions = {
89
+ catalogs: Catalogs
90
+ defaultLocale: string
91
+ fallbackLocale: string
92
+ }
93
+
94
+ type Catalogs = { [x: string]: Messages;}
95
+
96
+ type LocaleResolver = 'query' | 'cookie' | 'accept-header'
97
+
98
+ type Messages = { [key: string]: string | Messages;}
99
+
100
+ type Replacements = { [x: string]: string | number;}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerotal/i18n",
3
- "version": "1.6.3",
3
+ "version": "1.7.0",
4
4
  "license": "MIT",
5
5
  "maturity": "stable",
6
6
  "private": false,
@@ -12,6 +12,7 @@
12
12
  },
13
13
  "files": [
14
14
  "CHANGELOG.md",
15
+ "api-surface.md",
15
16
  "src",
16
17
  "!src/**/*.test.ts",
17
18
  "!src/**/*.test.tsx",
@@ -32,7 +33,7 @@
32
33
  "typecheck": "tsc --noEmit"
33
34
  },
34
35
  "dependencies": {
35
- "@zerotal/core": "1.6.3"
36
+ "@zerotal/core": "1.7.0"
36
37
  },
37
38
  "devDependencies": {
38
39
  "typescript": "^5.8.0"