@cliff-format/i18n 0.0.0-stage → 0.2.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,135 @@
1
+ import { p as IcuDialect, o as IcuAnalysis, b as IcuRuntime, n as I18nRuntime, O as TranslationScope, j as EntryIdInput, P as Params, Q as TypeTag, h as EmotionTag, K as StatusTag, v as MessagePart, u as MessageMetadata, g as CommitOptions, T as TFunction, U as VariantTag } from './types-CtbwKSot.cjs';
2
+ import { CliffEntry } from '@cliff-format/core';
3
+
4
+ declare function detectDialect(message: string): IcuDialect;
5
+ declare function argumentNames(message: string, dialect: IcuDialect): string[];
6
+ declare function analyzePlain(message: string, dialect: IcuDialect, errors?: IcuAnalysis["errors"]): IcuAnalysis;
7
+
8
+ declare function createLiteIcu(): IcuRuntime;
9
+
10
+ declare class MessageBuilderImpl {
11
+ private readonly i18n;
12
+ private readonly scope;
13
+ private readonly entryIdInput;
14
+ private sourceText;
15
+ private sourceParams;
16
+ private targetText;
17
+ private targetParams;
18
+ private extraParams;
19
+ private typeTag;
20
+ private inheritType;
21
+ private emotionTags;
22
+ private statusTag;
23
+ private contextText;
24
+ private maxWidthCells;
25
+ private referencePaths;
26
+ private reviewerName;
27
+ private extensionMap;
28
+ private localeOverride;
29
+ constructor(i18n: I18nRuntime, scope: TranslationScope, entryIdInput: EntryIdInput);
30
+ source(text: string, params?: Params): MessageBuilderImpl;
31
+ type(tag: TypeTag): MessageBuilderImpl;
32
+ typeFromGroup(): MessageBuilderImpl;
33
+ emotion(...tags: readonly (EmotionTag | readonly EmotionTag[])[]): MessageBuilderImpl;
34
+ context(text: string): MessageBuilderImpl;
35
+ maxWidth(cells: number): MessageBuilderImpl;
36
+ reference(...paths: string[]): MessageBuilderImpl;
37
+ reviewer(name: string): MessageBuilderImpl;
38
+ extension(name: string, value: string): MessageBuilderImpl;
39
+ target(text: string, params?: Params): MessageBuilderImpl;
40
+ status(tag: StatusTag): MessageBuilderImpl;
41
+ locale(tag: string): MessageBuilderImpl;
42
+ params(params: Params): MessageBuilderImpl;
43
+ count(value: number): MessageBuilderImpl;
44
+ private activeLocale;
45
+ private resolved;
46
+ private recordFor;
47
+ private mergedParams;
48
+ private diagnose;
49
+ private requireEffectiveType;
50
+ private ensureAuthoringMetadata;
51
+ private groupEmotion;
52
+ private requireEmotionIfConfigured;
53
+ private createDraft;
54
+ private checkWidth;
55
+ private renderRecord;
56
+ private expectationDiagnostics;
57
+ private missing;
58
+ render(params?: Params): string;
59
+ renderToParts(params?: Params): MessagePart[];
60
+ meta(): MessageMetadata;
61
+ entry(): CliffEntry | undefined;
62
+ commit(options?: CommitOptions): MessageBuilderImpl;
63
+ private applyOverwrite;
64
+ private validateDocument;
65
+ width(params?: Params): number;
66
+ fits(params?: Params): boolean;
67
+ toString(): string;
68
+ }
69
+ declare function createT<EntryIds extends string = string>(i18n: I18nRuntime, scope: TranslationScope): TFunction<EntryIds>;
70
+
71
+ declare class CliffI18nError extends Error {
72
+ constructor(message: string, options?: {
73
+ cause?: unknown;
74
+ });
75
+ }
76
+ declare class CliffScopeError extends CliffI18nError {
77
+ readonly scope: Partial<TranslationScope>;
78
+ constructor(message: string, scope?: Partial<TranslationScope>);
79
+ }
80
+ declare class CliffScopeMismatchError extends CliffScopeError {
81
+ readonly entryId: string;
82
+ constructor(entryId: string, scope: TranslationScope, expected: string);
83
+ }
84
+ declare class CliffMissingEntryError extends CliffI18nError {
85
+ readonly entryId: string;
86
+ readonly locale: string;
87
+ constructor(entryId: string, locale: string);
88
+ }
89
+ declare class CliffAmbiguousEntryError extends CliffI18nError {
90
+ readonly entryId: string;
91
+ readonly candidates: readonly string[];
92
+ constructor(entryId: string, candidates: readonly string[]);
93
+ }
94
+ declare class CliffDuplicateEntryError extends CliffI18nError {
95
+ readonly entryId: string;
96
+ readonly locale: string;
97
+ constructor(entryId: string, locale: string);
98
+ }
99
+ declare class CliffMissingMetadataError extends CliffI18nError {
100
+ readonly entryId: string;
101
+ readonly fields: readonly string[];
102
+ constructor(entryId: string, fields: readonly string[], detail?: string);
103
+ }
104
+ declare class CliffIcuError extends CliffI18nError {
105
+ readonly messageText: string;
106
+ constructor(messageText: string, detail: string);
107
+ }
108
+
109
+ declare const STATUS_TRANSITIONS: Record<StatusTag, readonly StatusTag[]>;
110
+ declare function statusOf(entry: CliffEntry): StatusTag;
111
+ declare function canTransitionStatus(from: StatusTag, to: StatusTag): boolean;
112
+ interface StatusContext {
113
+ source?: string;
114
+ target?: string;
115
+ explicit?: StatusTag;
116
+ }
117
+ /**
118
+ * Return the status a write should leave on an entry.
119
+ * An explicit status wins. Otherwise a missing target is initial, and a changed
120
+ * source or reworked reviewed/final target returns to translated.
121
+ */
122
+ declare function reconcileEntryStatus(entry: CliffEntry, previous?: StatusContext): StatusTag;
123
+ declare function nextStatuses(status: StatusTag): readonly StatusTag[];
124
+ declare function statusOrder(): readonly StatusTag[];
125
+
126
+ declare function isTypeTag(value: string): value is TypeTag;
127
+ declare function isEmotionTag(value: string): value is EmotionTag;
128
+ declare function isStatusTag(value: string): value is StatusTag;
129
+ declare function isVariantTag(value: string): value is VariantTag;
130
+ declare function assertTypeTag(value: string): TypeTag;
131
+ declare function assertEmotionTag(value: string): EmotionTag;
132
+ declare function assertStatusTag(value: string): StatusTag;
133
+ declare function assertVariantTag(value: string): VariantTag;
134
+
135
+ export { CliffAmbiguousEntryError as C, MessageBuilderImpl as M, STATUS_TRANSITIONS as S, CliffDuplicateEntryError as a, CliffI18nError as b, CliffIcuError as c, CliffMissingEntryError as d, CliffMissingMetadataError as e, CliffScopeError as f, CliffScopeMismatchError as g, type StatusContext as h, analyzePlain as i, argumentNames as j, assertEmotionTag as k, assertStatusTag as l, assertTypeTag as m, assertVariantTag as n, canTransitionStatus as o, createLiteIcu as p, createT as q, detectDialect as r, isEmotionTag as s, isStatusTag as t, isTypeTag as u, isVariantTag as v, nextStatuses as w, reconcileEntryStatus as x, statusOf as y, statusOrder as z };
package/package.json CHANGED
@@ -1,6 +1,119 @@
1
1
  {
2
2
  "name": "@cliff-format/i18n",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "CLIFF-native runtime localization, authoring and ICU formatting",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "engines": {
9
+ "node": ">=22.12"
10
+ },
11
+ "main": "./dist/index.cjs",
12
+ "module": "./dist/index.js",
13
+ "types": "./dist/index.d.ts",
14
+ "exports": {
15
+ ".": {
16
+ "browser": {
17
+ "types": "./dist/index.d.ts",
18
+ "default": "./dist/index.js"
19
+ },
20
+ "import": {
21
+ "types": "./dist/index.d.ts",
22
+ "default": "./dist/index.js"
23
+ },
24
+ "require": {
25
+ "types": "./dist/index.d.cts",
26
+ "default": "./dist/index.cjs"
27
+ }
28
+ },
29
+ "./lite": {
30
+ "browser": {
31
+ "types": "./dist/lite.d.ts",
32
+ "default": "./dist/lite.js"
33
+ },
34
+ "import": {
35
+ "types": "./dist/lite.d.ts",
36
+ "default": "./dist/lite.js"
37
+ },
38
+ "require": {
39
+ "types": "./dist/lite.d.cts",
40
+ "default": "./dist/lite.cjs"
41
+ }
42
+ },
43
+ "./react": {
44
+ "browser": {
45
+ "types": "./dist/react.d.ts",
46
+ "default": "./dist/react.js"
47
+ },
48
+ "import": {
49
+ "types": "./dist/react.d.ts",
50
+ "default": "./dist/react.js"
51
+ },
52
+ "require": {
53
+ "types": "./dist/react.d.cts",
54
+ "default": "./dist/react.cjs"
55
+ }
56
+ },
57
+ "./package.json": "./package.json"
58
+ },
59
+ "typesVersions": {
60
+ "*": {
61
+ "lite": [
62
+ "dist/lite.d.ts"
63
+ ],
64
+ "react": [
65
+ "dist/react.d.ts"
66
+ ]
67
+ }
68
+ },
69
+ "files": [
70
+ "dist",
71
+ "README.md",
72
+ "LICENSE"
73
+ ],
74
+ "publishConfig": {
75
+ "access": "public"
76
+ },
77
+ "scripts": {
78
+ "build": "tsup",
79
+ "test": "vitest run"
80
+ },
81
+ "dependencies": {
82
+ "@messageformat/icu-messageformat-1": "^0.13.0",
83
+ "messageformat": "^4.1.0"
84
+ },
85
+ "peerDependencies": {
86
+ "@cliff-format/core": "^0.2.0",
87
+ "react": ">=18"
88
+ },
89
+ "peerDependenciesMeta": {
90
+ "react": {
91
+ "optional": true
92
+ }
93
+ },
94
+ "devDependencies": {
95
+ "@cliff-format/core": "workspace:*",
96
+ "@types/react": "^19.0.0",
97
+ "react": "^19.0.0",
98
+ "react-dom": "^19.0.0",
99
+ "@types/react-dom": "^19.0.0"
100
+ },
101
+ "repository": {
102
+ "type": "git",
103
+ "url": "git+https://github.com/cliff-format/cliff-js.git",
104
+ "directory": "packages/i18n"
105
+ },
106
+ "keywords": [
107
+ "cliff",
108
+ "i18n",
109
+ "l10n",
110
+ "localization",
111
+ "icu",
112
+ "messageformat",
113
+ "react"
114
+ ],
115
+ "homepage": "https://github.com/cliff-format/cliff-js#readme",
116
+ "bugs": {
117
+ "url": "https://github.com/cliff-format/cliff-js/issues"
118
+ }
119
+ }