@chipmobilesdk/rn-i18n 0.3.0 → 0.4.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.
- package/CHANGELOG.md +157 -0
- package/README.md +28 -17
- package/lib/commonjs/config/catalog.js +29 -0
- package/lib/commonjs/config/catalog.js.map +1 -0
- package/lib/commonjs/config/diagnostics.js +56 -0
- package/lib/commonjs/config/diagnostics.js.map +1 -0
- package/lib/commonjs/config/errors.js +35 -0
- package/lib/commonjs/config/errors.js.map +1 -0
- package/lib/commonjs/config/types.js +13 -0
- package/lib/commonjs/config/types.js.map +1 -0
- package/lib/commonjs/config/validateConfig.js +134 -0
- package/lib/commonjs/config/validateConfig.js.map +1 -0
- package/lib/commonjs/format/currency.js +35 -0
- package/lib/commonjs/format/currency.js.map +1 -0
- package/lib/commonjs/format/date.js +36 -0
- package/lib/commonjs/format/date.js.map +1 -0
- package/lib/commonjs/format/invalid.js +24 -0
- package/lib/commonjs/format/invalid.js.map +1 -0
- package/lib/commonjs/format/number.js +29 -0
- package/lib/commonjs/format/number.js.map +1 -0
- package/lib/commonjs/format/units.js +184 -0
- package/lib/commonjs/format/units.js.map +1 -0
- package/lib/commonjs/i18n.js +234 -0
- package/lib/commonjs/i18n.js.map +1 -0
- package/lib/commonjs/index.js +93 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/locale/activeLocale.js +37 -0
- package/lib/commonjs/locale/activeLocale.js.map +1 -0
- package/lib/commonjs/locale/deviceLocale.js +52 -0
- package/lib/commonjs/locale/deviceLocale.js.map +1 -0
- package/lib/commonjs/locale/keyValueStorage.js +29 -0
- package/lib/commonjs/locale/keyValueStorage.js.map +1 -0
- package/lib/commonjs/locale/persistence.js +74 -0
- package/lib/commonjs/locale/persistence.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/react/I18nProvider.js +36 -0
- package/lib/commonjs/react/I18nProvider.js.map +1 -0
- package/lib/commonjs/react/hooks.js +47 -0
- package/lib/commonjs/react/hooks.js.map +1 -0
- package/lib/commonjs/translation/interpolate.js +24 -0
- package/lib/commonjs/translation/interpolate.js.map +1 -0
- package/lib/commonjs/translation/plurals.js +122 -0
- package/lib/commonjs/translation/plurals.js.map +1 -0
- package/lib/commonjs/translation/resolver.js +124 -0
- package/lib/commonjs/translation/resolver.js.map +1 -0
- package/lib/commonjs/translation/runtimeKeys.js +55 -0
- package/lib/commonjs/translation/runtimeKeys.js.map +1 -0
- package/lib/module/config/catalog.js +25 -0
- package/lib/module/config/catalog.js.map +1 -0
- package/lib/module/config/diagnostics.js +51 -0
- package/lib/module/config/diagnostics.js.map +1 -0
- package/lib/module/config/errors.js +30 -0
- package/lib/module/config/errors.js.map +1 -0
- package/lib/module/config/types.js +26 -0
- package/lib/module/config/types.js.map +1 -0
- package/lib/module/config/validateConfig.js +131 -0
- package/lib/module/config/validateConfig.js.map +1 -0
- package/lib/module/format/currency.js +32 -0
- package/lib/module/format/currency.js.map +1 -0
- package/lib/module/format/date.js +33 -0
- package/lib/module/format/date.js.map +1 -0
- package/lib/module/format/invalid.js +21 -0
- package/lib/module/format/invalid.js.map +1 -0
- package/lib/module/format/number.js +26 -0
- package/lib/module/format/number.js.map +1 -0
- package/lib/module/format/units.js +171 -0
- package/lib/module/format/units.js.map +1 -0
- package/lib/module/i18n.js +230 -0
- package/lib/module/i18n.js.map +1 -0
- package/lib/module/index.js +23 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/locale/activeLocale.js +33 -0
- package/lib/module/locale/activeLocale.js.map +1 -0
- package/lib/module/locale/deviceLocale.js +46 -0
- package/lib/module/locale/deviceLocale.js.map +1 -0
- package/lib/module/locale/keyValueStorage.js +25 -0
- package/lib/module/locale/keyValueStorage.js.map +1 -0
- package/lib/module/locale/persistence.js +66 -0
- package/lib/module/locale/persistence.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/react/I18nProvider.js +29 -0
- package/lib/module/react/I18nProvider.js.map +1 -0
- package/lib/module/react/hooks.js +42 -0
- package/lib/module/react/hooks.js.map +1 -0
- package/lib/module/translation/interpolate.js +20 -0
- package/lib/module/translation/interpolate.js.map +1 -0
- package/lib/module/translation/plurals.js +114 -0
- package/lib/module/translation/plurals.js.map +1 -0
- package/lib/module/translation/resolver.js +118 -0
- package/lib/module/translation/resolver.js.map +1 -0
- package/lib/module/translation/runtimeKeys.js +50 -0
- package/lib/module/translation/runtimeKeys.js.map +1 -0
- package/lib/typescript/commonjs/config/catalog.d.ts +18 -0
- package/lib/typescript/commonjs/config/catalog.d.ts.map +1 -0
- package/lib/typescript/commonjs/config/diagnostics.d.ts +21 -0
- package/lib/typescript/commonjs/config/diagnostics.d.ts.map +1 -0
- package/lib/typescript/commonjs/config/errors.d.ts +16 -0
- package/lib/typescript/commonjs/config/errors.d.ts.map +1 -0
- package/lib/typescript/commonjs/config/types.d.ts +127 -0
- package/lib/typescript/commonjs/config/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/config/validateConfig.d.ts +8 -0
- package/lib/typescript/commonjs/config/validateConfig.d.ts.map +1 -0
- package/lib/typescript/commonjs/format/currency.d.ts +12 -0
- package/lib/typescript/commonjs/format/currency.d.ts.map +1 -0
- package/lib/typescript/commonjs/format/date.d.ts +14 -0
- package/lib/typescript/commonjs/format/date.d.ts.map +1 -0
- package/lib/typescript/commonjs/format/invalid.d.ts +12 -0
- package/lib/typescript/commonjs/format/invalid.d.ts.map +1 -0
- package/lib/typescript/commonjs/format/number.d.ts +8 -0
- package/lib/typescript/commonjs/format/number.d.ts.map +1 -0
- package/lib/typescript/commonjs/format/units.d.ts +23 -0
- package/lib/typescript/commonjs/format/units.d.ts.map +1 -0
- package/lib/typescript/commonjs/i18n.d.ts +46 -0
- package/lib/typescript/commonjs/i18n.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +27 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/locale/activeLocale.d.ts +17 -0
- package/lib/typescript/commonjs/locale/activeLocale.d.ts.map +1 -0
- package/lib/typescript/commonjs/locale/deviceLocale.d.ts +19 -0
- package/lib/typescript/commonjs/locale/deviceLocale.d.ts.map +1 -0
- package/lib/typescript/commonjs/locale/keyValueStorage.d.ts +13 -0
- package/lib/typescript/commonjs/locale/keyValueStorage.d.ts.map +1 -0
- package/lib/typescript/commonjs/locale/persistence.d.ts +24 -0
- package/lib/typescript/commonjs/locale/persistence.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/react/I18nProvider.d.ts +16 -0
- package/lib/typescript/commonjs/react/I18nProvider.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/hooks.d.ts +21 -0
- package/lib/typescript/commonjs/react/hooks.d.ts.map +1 -0
- package/lib/typescript/commonjs/translation/interpolate.d.ts +8 -0
- package/lib/typescript/commonjs/translation/interpolate.d.ts.map +1 -0
- package/lib/typescript/commonjs/translation/plurals.d.ts +13 -0
- package/lib/typescript/commonjs/translation/plurals.d.ts.map +1 -0
- package/lib/typescript/commonjs/translation/resolver.d.ts +24 -0
- package/lib/typescript/commonjs/translation/resolver.d.ts.map +1 -0
- package/lib/typescript/commonjs/translation/runtimeKeys.d.ts +16 -0
- package/lib/typescript/commonjs/translation/runtimeKeys.d.ts.map +1 -0
- package/lib/typescript/module/config/catalog.d.ts +18 -0
- package/lib/typescript/module/config/catalog.d.ts.map +1 -0
- package/lib/typescript/module/config/diagnostics.d.ts +21 -0
- package/lib/typescript/module/config/diagnostics.d.ts.map +1 -0
- package/lib/typescript/module/config/errors.d.ts +16 -0
- package/lib/typescript/module/config/errors.d.ts.map +1 -0
- package/lib/typescript/module/config/types.d.ts +127 -0
- package/lib/typescript/module/config/types.d.ts.map +1 -0
- package/lib/typescript/module/config/validateConfig.d.ts +8 -0
- package/lib/typescript/module/config/validateConfig.d.ts.map +1 -0
- package/lib/typescript/module/format/currency.d.ts +12 -0
- package/lib/typescript/module/format/currency.d.ts.map +1 -0
- package/lib/typescript/module/format/date.d.ts +14 -0
- package/lib/typescript/module/format/date.d.ts.map +1 -0
- package/lib/typescript/module/format/invalid.d.ts +12 -0
- package/lib/typescript/module/format/invalid.d.ts.map +1 -0
- package/lib/typescript/module/format/number.d.ts +8 -0
- package/lib/typescript/module/format/number.d.ts.map +1 -0
- package/lib/typescript/module/format/units.d.ts +23 -0
- package/lib/typescript/module/format/units.d.ts.map +1 -0
- package/lib/typescript/module/i18n.d.ts +46 -0
- package/lib/typescript/module/i18n.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +27 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/locale/activeLocale.d.ts +17 -0
- package/lib/typescript/module/locale/activeLocale.d.ts.map +1 -0
- package/lib/typescript/module/locale/deviceLocale.d.ts +19 -0
- package/lib/typescript/module/locale/deviceLocale.d.ts.map +1 -0
- package/lib/typescript/module/locale/keyValueStorage.d.ts +13 -0
- package/lib/typescript/module/locale/keyValueStorage.d.ts.map +1 -0
- package/lib/typescript/module/locale/persistence.d.ts +24 -0
- package/lib/typescript/module/locale/persistence.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/react/I18nProvider.d.ts +16 -0
- package/lib/typescript/module/react/I18nProvider.d.ts.map +1 -0
- package/lib/typescript/module/react/hooks.d.ts +21 -0
- package/lib/typescript/module/react/hooks.d.ts.map +1 -0
- package/lib/typescript/module/translation/interpolate.d.ts +8 -0
- package/lib/typescript/module/translation/interpolate.d.ts.map +1 -0
- package/lib/typescript/module/translation/plurals.d.ts +13 -0
- package/lib/typescript/module/translation/plurals.d.ts.map +1 -0
- package/lib/typescript/module/translation/resolver.d.ts +24 -0
- package/lib/typescript/module/translation/resolver.d.ts.map +1 -0
- package/lib/typescript/module/translation/runtimeKeys.d.ts +16 -0
- package/lib/typescript/module/translation/runtimeKeys.d.ts.map +1 -0
- package/package.json +41 -18
- package/src/index.ts +5 -3
- package/src/tooling/cli.ts +0 -76
- package/src/tooling/generateKeys.ts +0 -65
- package/src/tooling/index.ts +0 -27
- package/src/tooling/report.ts +0 -109
- package/src/tooling/runner.ts +0 -111
- package/src/tooling/scan.ts +0 -193
- package/src/tooling/sync.ts +0 -193
- package/src/tooling/types.ts +0 -119
package/src/tooling/types.ts
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared contracts for the Node-only extraction and synchronization tooling.
|
|
3
|
-
* This module must stay free of React Native imports; it is consumed through
|
|
4
|
-
* the `@chipmobilesdk/rn-i18n/tooling` entrypoint and the CLI.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export interface PatternConfig {
|
|
8
|
-
/**
|
|
9
|
-
* Regex source with a named `key` capture group for statically resolvable
|
|
10
|
-
* keys, and an optional named `defaultText` group for template values.
|
|
11
|
-
*/
|
|
12
|
-
regex: string;
|
|
13
|
-
/** Extra regex flags; `g` is always applied. */
|
|
14
|
-
flags?: string;
|
|
15
|
-
/**
|
|
16
|
-
* Optional regex matching dynamic usages of the same call style. Matches
|
|
17
|
-
* that do not overlap a static key match are reported as ambiguous.
|
|
18
|
-
*/
|
|
19
|
-
ambiguousRegex?: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface SyncConfig {
|
|
23
|
-
/** Globs relative to the project root, e.g. `src/**\/*.{ts,tsx}`. */
|
|
24
|
-
sourceGlobs: string[];
|
|
25
|
-
patterns: PatternConfig[];
|
|
26
|
-
/** Directory containing `<locale>.json` files. */
|
|
27
|
-
localesDir: string;
|
|
28
|
-
locales: string[];
|
|
29
|
-
/** Module exporting the declared runtime-only entries. */
|
|
30
|
-
runtimeEntriesFile?: string;
|
|
31
|
-
/**
|
|
32
|
-
* Value written for newly added keys: `template` uses the discovered
|
|
33
|
-
* default text (falling back to the key), a string is used verbatim, and
|
|
34
|
-
* a map selects per locale. Default: `template`.
|
|
35
|
-
*/
|
|
36
|
-
placeholder?: 'template' | string | Record<string, string>;
|
|
37
|
-
/** Optional JSON report output path. */
|
|
38
|
-
reportPath?: string;
|
|
39
|
-
/** Generated typed key artifact path, e.g. `src/i18n/keys.generated.ts`. */
|
|
40
|
-
generateKeysFile?: string;
|
|
41
|
-
/** Exported key type name. Default: `AppI18nKey`. */
|
|
42
|
-
keysTypeName?: string;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface RuntimeEntryConfig {
|
|
46
|
-
key: string;
|
|
47
|
-
defaultText: string;
|
|
48
|
-
policy?: 'add' | 'report';
|
|
49
|
-
description?: string;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface SourceLocation {
|
|
53
|
-
file: string;
|
|
54
|
-
line: number;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface TemplateKey {
|
|
58
|
-
key: string;
|
|
59
|
-
defaultText?: string;
|
|
60
|
-
locations: SourceLocation[];
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export interface AmbiguousUsage {
|
|
64
|
-
file: string;
|
|
65
|
-
line: number;
|
|
66
|
-
snippet: string;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface KeyConflict {
|
|
70
|
-
key: string;
|
|
71
|
-
values: { text: string; location: SourceLocation }[];
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export interface TranslationTemplate {
|
|
75
|
-
/** Discovered keys sorted by key name. */
|
|
76
|
-
keys: TemplateKey[];
|
|
77
|
-
ambiguous: AmbiguousUsage[];
|
|
78
|
-
conflicts: KeyConflict[];
|
|
79
|
-
scannedFiles: number;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export interface LocaleSyncResult {
|
|
83
|
-
locale: string;
|
|
84
|
-
filePath: string;
|
|
85
|
-
created: boolean;
|
|
86
|
-
addedKeys: string[];
|
|
87
|
-
preservedKeys: string[];
|
|
88
|
-
removedKeys: string[];
|
|
89
|
-
runtimePreserved: string[];
|
|
90
|
-
runtimeAdded: string[];
|
|
91
|
-
runtimeReported: string[];
|
|
92
|
-
/** Set when the locale file is malformed; no write happened. */
|
|
93
|
-
error?: string;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export type ReportOutcome = 'success' | 'completedWithWarnings' | 'failed';
|
|
97
|
-
|
|
98
|
-
export interface ExtractionReport {
|
|
99
|
-
outcome: ReportOutcome;
|
|
100
|
-
discovered: {
|
|
101
|
-
key: string;
|
|
102
|
-
defaultText?: string;
|
|
103
|
-
locations: string[];
|
|
104
|
-
}[];
|
|
105
|
-
createdLocaleFiles: { locale: string; filePath: string }[];
|
|
106
|
-
addedKeys: Record<string, string[]>;
|
|
107
|
-
preservedKeys: Record<string, string[]>;
|
|
108
|
-
removedStaleKeys: Record<string, string[]>;
|
|
109
|
-
missingPerLocale: Record<string, string[]>;
|
|
110
|
-
runtimeOnly: {
|
|
111
|
-
declared: string[];
|
|
112
|
-
preserved: Record<string, string[]>;
|
|
113
|
-
added: Record<string, string[]>;
|
|
114
|
-
reported: Record<string, string[]>;
|
|
115
|
-
};
|
|
116
|
-
ambiguous: AmbiguousUsage[];
|
|
117
|
-
conflicts: KeyConflict[];
|
|
118
|
-
errors: string[];
|
|
119
|
-
}
|