@worldware/msg 0.8.0 → 0.9.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 (39) hide show
  1. package/dist/chunk-DJFPVXQ5.mjs +69 -0
  2. package/dist/chunk-F3VAAZJZ.mjs +124 -0
  3. package/dist/chunk-IMOOTZIK.mjs +274 -0
  4. package/dist/chunk-ORHP7HGX.mjs +0 -0
  5. package/dist/chunk-PU7ZZ5XH.mjs +13 -0
  6. package/dist/chunk-XQVALCKX.mjs +12 -0
  7. package/dist/classes/MsgInterface/MsgInterface.cjs +37 -0
  8. package/dist/classes/MsgInterface/MsgInterface.d.cts +54 -0
  9. package/dist/classes/MsgInterface/MsgInterface.d.ts +54 -0
  10. package/dist/classes/MsgInterface/MsgInterface.mjs +8 -0
  11. package/dist/classes/MsgMessage/MsgMessage.cjs +153 -0
  12. package/dist/classes/MsgMessage/MsgMessage.d.cts +92 -0
  13. package/dist/classes/MsgMessage/MsgMessage.d.ts +92 -0
  14. package/dist/classes/MsgMessage/MsgMessage.mjs +7 -0
  15. package/dist/classes/MsgProject/MsgProject.cjs +94 -0
  16. package/dist/classes/MsgProject/MsgProject.d.cts +4 -0
  17. package/dist/classes/MsgProject/MsgProject.d.ts +4 -0
  18. package/dist/classes/MsgProject/MsgProject.mjs +7 -0
  19. package/dist/classes/MsgResource/MsgResource.cjs +418 -0
  20. package/dist/classes/MsgResource/MsgResource.d.cts +201 -0
  21. package/dist/classes/MsgResource/MsgResource.d.ts +201 -0
  22. package/dist/classes/MsgResource/MsgResource.mjs +8 -0
  23. package/dist/classes/index.cjs +486 -0
  24. package/dist/classes/index.d.cts +4 -0
  25. package/dist/classes/index.d.ts +4 -0
  26. package/dist/classes/index.mjs +21 -0
  27. package/dist/index.cjs +486 -0
  28. package/dist/index.d.cts +4 -0
  29. package/dist/index.d.ts +4 -0
  30. package/dist/index.mjs +21 -0
  31. package/dist/lib/index.cjs +40 -0
  32. package/dist/lib/index.d.cts +1 -0
  33. package/dist/lib/index.d.ts +1 -0
  34. package/dist/lib/index.mjs +8 -0
  35. package/dist/lib/lang-utils.cjs +38 -0
  36. package/dist/lib/lang-utils.d.cts +14 -0
  37. package/dist/lib/lang-utils.d.ts +14 -0
  38. package/dist/lib/lang-utils.mjs +8 -0
  39. package/package.json +2 -1
@@ -0,0 +1,69 @@
1
+ import {
2
+ MSG_DEFAULT_FORMAT
3
+ } from "./chunk-XQVALCKX.mjs";
4
+
5
+ // src/classes/MsgProject/MsgProject.ts
6
+ var defaultProjectSettings = {
7
+ name: "messages",
8
+ version: 1,
9
+ format: MSG_DEFAULT_FORMAT
10
+ };
11
+ var defaultLocalesSettings = {
12
+ sourceLocale: "en",
13
+ pseudoLocale: "en-XA",
14
+ targetLocales: {
15
+ en: ["en"]
16
+ }
17
+ };
18
+ var MsgProject = class _MsgProject {
19
+ /** Project name, version, and default format. */
20
+ _project;
21
+ /** Source, pseudo, and target locale settings. */
22
+ _locales;
23
+ /** Function used to load translations for a locale. */
24
+ _loader;
25
+ /**
26
+ * Builds a project from {@link MsgProjectData}.
27
+ */
28
+ static create(data) {
29
+ const { project, locales, loader } = data;
30
+ return new _MsgProject(project, locales, loader);
31
+ }
32
+ /**
33
+ * Creates a project from its settings and loader. Prefer {@link MsgProject.create}.
34
+ */
35
+ constructor(projectSettings, localesSettings, loader) {
36
+ this._project = { ...defaultProjectSettings, ...projectSettings };
37
+ this._locales = { ...defaultLocalesSettings, ...localesSettings };
38
+ this._loader = loader;
39
+ }
40
+ /** Project name, version, and default format. */
41
+ get project() {
42
+ return this._project;
43
+ }
44
+ /** Source, pseudo, and target locale settings. */
45
+ get locales() {
46
+ return this._locales;
47
+ }
48
+ /** Function used to load translations for a locale. */
49
+ get loader() {
50
+ return this._loader;
51
+ }
52
+ /**
53
+ * The project-wide default message format. Resources (and, through them,
54
+ * messages) inherit this value unless they specify their own.
55
+ */
56
+ get format() {
57
+ return this._project.format ?? MSG_DEFAULT_FORMAT;
58
+ }
59
+ /**
60
+ * Returns the translation load chain for a locale, or `undefined` if unsupported.
61
+ */
62
+ getTargetLocale(locale) {
63
+ return this._locales.targetLocales[locale];
64
+ }
65
+ };
66
+
67
+ export {
68
+ MsgProject
69
+ };
@@ -0,0 +1,124 @@
1
+ import {
2
+ DEFAULT_ATTRIBUTES,
3
+ MSG_DEFAULT_FORMAT
4
+ } from "./chunk-XQVALCKX.mjs";
5
+
6
+ // src/classes/MsgMessage/MsgMessage.ts
7
+ import { MessageFormat } from "messageformat";
8
+ import { mf1ToMessage } from "@messageformat/icu-messageformat-1";
9
+ var MsgMessage = class _MsgMessage {
10
+ _key;
11
+ _value;
12
+ _mf;
13
+ _attributes;
14
+ _notes = [];
15
+ /**
16
+ * Creates a message from its parts. Prefer {@link MsgMessage.create}.
17
+ */
18
+ constructor(key, value, attributes, notes) {
19
+ this._key = key;
20
+ this._value = value;
21
+ this._attributes = attributes ? { ...DEFAULT_ATTRIBUTES, ...attributes } : {};
22
+ if (notes) {
23
+ notes.forEach((note) => this.addNote(note));
24
+ }
25
+ }
26
+ /**
27
+ * Builds a message from {@link MsgMessageData}.
28
+ */
29
+ static create(data) {
30
+ const { key, value, attributes, notes } = data;
31
+ const message = new _MsgMessage(key, value, attributes, notes);
32
+ return message;
33
+ }
34
+ /** Unique key that identifies this message within a resource. */
35
+ get key() {
36
+ return this._key;
37
+ }
38
+ /** The message string, possibly in MessageFormat syntax. */
39
+ get value() {
40
+ return this._value;
41
+ }
42
+ /** Locale and formatting metadata for this message. */
43
+ get attributes() {
44
+ return this._attributes;
45
+ }
46
+ /** Notes attached to this message for translators and tooling. */
47
+ get notes() {
48
+ return this._notes;
49
+ }
50
+ /**
51
+ * Appends a note to this message.
52
+ */
53
+ addNote(note) {
54
+ this.notes.push(note);
55
+ }
56
+ /**
57
+ * The message's resolved format, defaulting to MF2 when not set or inherited.
58
+ */
59
+ resolveFormat() {
60
+ return this.attributes.format ?? MSG_DEFAULT_FORMAT;
61
+ }
62
+ /**
63
+ * Returns a cached MessageFormat formatter for this message's value.
64
+ */
65
+ getFormatter(options) {
66
+ if (!this._mf) {
67
+ this._mf = this.resolveFormat() === "MF1" ? mf1ToMessage(this.attributes.lang, this.value, options) : new MessageFormat(this.attributes.lang, this.value, options);
68
+ }
69
+ return this._mf;
70
+ }
71
+ /**
72
+ * Formats the message with the given placeholder data.
73
+ *
74
+ * For `NONE` format messages, returns the raw value unchanged.
75
+ */
76
+ format(data, options) {
77
+ if (this.resolveFormat() === "NONE") {
78
+ return this.value;
79
+ }
80
+ return this.getFormatter(options).format(data);
81
+ }
82
+ /**
83
+ * Formats the message into structured parts with the given placeholder data.
84
+ *
85
+ * For `NONE` format messages, returns a single text part with the raw value.
86
+ */
87
+ formatToParts(data, options) {
88
+ if (this.resolveFormat() === "NONE") {
89
+ return [{ type: "text", value: this.value }];
90
+ }
91
+ return this.getFormatter(options).formatToParts(data);
92
+ }
93
+ /**
94
+ * Returns a plain data object for this message.
95
+ *
96
+ * @param stripNotes - When true, notes are omitted from the result.
97
+ */
98
+ getData(stripNotes = false) {
99
+ return {
100
+ key: this.key,
101
+ value: this.value,
102
+ attributes: this.attributes,
103
+ notes: !stripNotes && this.notes.length > 0 ? this.notes : void 0
104
+ };
105
+ }
106
+ /**
107
+ * Returns the message value as a string.
108
+ */
109
+ toString() {
110
+ return this.value;
111
+ }
112
+ /**
113
+ * Serializes this message to a formatted JSON string.
114
+ *
115
+ * @param stripNotes - When true, notes are omitted from the serialized data.
116
+ */
117
+ toJSON(stripNotes = false) {
118
+ return JSON.stringify(this.getData(stripNotes), null, 2);
119
+ }
120
+ };
121
+
122
+ export {
123
+ MsgMessage
124
+ };
@@ -0,0 +1,274 @@
1
+ import {
2
+ MsgMessage
3
+ } from "./chunk-F3VAAZJZ.mjs";
4
+ import {
5
+ DEFAULT_ATTRIBUTES,
6
+ MSG_DEFAULT_FORMAT
7
+ } from "./chunk-XQVALCKX.mjs";
8
+
9
+ // src/classes/MsgResource/MsgResource.ts
10
+ import { parseMessage, stringifyMessage, visit } from "messageformat";
11
+ import { localize } from "pseudo-localization";
12
+ var MsgResource = class _MsgResource extends Map {
13
+ _attributes = {};
14
+ _notes = [];
15
+ _title;
16
+ _project;
17
+ /**
18
+ * Builds a resource from {@link MsgResourceData} and an owning project.
19
+ *
20
+ * When `messages` is provided, each entry is added to the resource.
21
+ * When omitted, the resource starts empty.
22
+ */
23
+ static create(data, project) {
24
+ const { title, attributes, notes, messages } = data;
25
+ const res = new _MsgResource(title, attributes, project, notes);
26
+ if (messages) {
27
+ messages.forEach((messageData) => {
28
+ const { key, value, attributes: attributes2, notes: notes2 } = messageData;
29
+ res.add(key, value, attributes2, notes2);
30
+ });
31
+ } else {
32
+ res.clear();
33
+ }
34
+ return res;
35
+ }
36
+ /**
37
+ * Creates a resource bound to a project. Prefer {@link MsgResource.create}.
38
+ */
39
+ constructor(title, attributes, project, notes) {
40
+ super();
41
+ this._title = title;
42
+ this._attributes = { ...DEFAULT_ATTRIBUTES, format: project.format, ...attributes };
43
+ this._project = project;
44
+ if (notes) {
45
+ notes.forEach((note) => this.addNote(note));
46
+ }
47
+ }
48
+ /**
49
+ * Returns true when the message's attributes match this resource's attributes.
50
+ */
51
+ hasMatchingAttributes(message) {
52
+ const res = this.attributes;
53
+ const msg = message.attributes;
54
+ return res.lang === msg.lang && res.dir === msg.dir && res.dnt === msg.dnt && this.resolveFormat(res) === this.resolveFormat(msg);
55
+ }
56
+ /**
57
+ * Resolves a format from attributes, falling back to the library default.
58
+ */
59
+ resolveFormat(attributes) {
60
+ return attributes.format ?? MSG_DEFAULT_FORMAT;
61
+ }
62
+ /**
63
+ * Pseudo-localizes an MF2 message by localizing only literal text parts.
64
+ */
65
+ pseudoLocalizeMF2(source, options) {
66
+ const msg = parseMessage(source);
67
+ visit(msg, {
68
+ pattern: (pattern) => {
69
+ for (let i = 0; i < pattern.length; i++) {
70
+ const part = pattern[i];
71
+ if (typeof part === "string") {
72
+ pattern[i] = localize(part, options);
73
+ }
74
+ }
75
+ }
76
+ });
77
+ return stringifyMessage(msg);
78
+ }
79
+ /** Locale and formatting metadata for this resource. */
80
+ get attributes() {
81
+ return this._attributes;
82
+ }
83
+ /** Replaces the resource's locale and formatting metadata. */
84
+ set attributes(attributes) {
85
+ this._attributes = attributes;
86
+ }
87
+ /** Notes attached to this resource for translators and tooling. */
88
+ get notes() {
89
+ return this._notes;
90
+ }
91
+ /** Replaces the notes attached to this resource. */
92
+ set notes(notes) {
93
+ this._notes = notes;
94
+ }
95
+ /**
96
+ * Appends a note to this resource.
97
+ */
98
+ addNote(note) {
99
+ this.notes.push(note);
100
+ }
101
+ /** Title that identifies this resource within a project. */
102
+ get title() {
103
+ return this._title;
104
+ }
105
+ /** Sets the title that identifies this resource within a project. */
106
+ set title(title) {
107
+ this._title = title;
108
+ }
109
+ /**
110
+ * Returns the project this resource belongs to.
111
+ */
112
+ getProject() {
113
+ return this._project;
114
+ }
115
+ /**
116
+ * Adds a message to this resource, merging resource attributes with any overrides.
117
+ *
118
+ * @returns This resource, for chaining.
119
+ */
120
+ add(key, value, attributes, notes) {
121
+ const merged = { ...this.attributes, ...attributes };
122
+ const msg = MsgMessage.create({
123
+ key,
124
+ value,
125
+ attributes: merged,
126
+ notes
127
+ });
128
+ this.set(key, msg);
129
+ return this;
130
+ }
131
+ /**
132
+ * Builds a translated copy of this resource from translation data.
133
+ *
134
+ * Messages present in the translation replace the source; missing keys keep
135
+ * the source message. Notes are carried over from the source.
136
+ *
137
+ * @throws {TypeError} When the translation title does not match this resource.
138
+ */
139
+ translate(data) {
140
+ const { title, attributes, messages } = data;
141
+ if (title !== this.title) {
142
+ throw new TypeError("Title of resource and translations do not match.");
143
+ }
144
+ const translated = _MsgResource.create({
145
+ title,
146
+ // preserve the source resource's format unless the translation overrides it
147
+ attributes: this.preserveFormat(attributes, this.attributes.format),
148
+ notes: this.notes
149
+ // transfer the notes
150
+ }, this._project);
151
+ this.forEach((msg) => {
152
+ translated.set(msg.key, msg);
153
+ });
154
+ messages?.forEach((messageData) => {
155
+ const { key, value, attributes: attributes2 } = messageData;
156
+ const msg = MsgMessage.create({
157
+ key,
158
+ value,
159
+ // preserve the source message's format unless the translation overrides it
160
+ attributes: this.preserveFormat(attributes2, this.get(key)?.attributes.format)
161
+ });
162
+ const notes = this.get(key)?.notes || [];
163
+ notes.forEach((note) => {
164
+ msg.addNote(note);
165
+ });
166
+ translated.set(key, msg);
167
+ });
168
+ return translated;
169
+ }
170
+ preserveFormat(attributes, format) {
171
+ if (format === void 0 || attributes?.format !== void 0) {
172
+ return attributes;
173
+ }
174
+ return { ...attributes, format };
175
+ }
176
+ /**
177
+ * Loads and applies translations for a locale via the project loader.
178
+ *
179
+ * When `lang` is the project's pseudo-locale, returns a pseudo-localized
180
+ * copy without calling the loader.
181
+ *
182
+ * @throws {Error} When the locale is unsupported or its language chain is empty.
183
+ */
184
+ async getTranslation(lang) {
185
+ if (!lang) {
186
+ return _MsgResource.create(this.getData(), this.getProject());
187
+ }
188
+ const project = this._project;
189
+ const pseudoLocale = project.locales.pseudoLocale;
190
+ if (lang === pseudoLocale) {
191
+ const pseudolocalizedData = {
192
+ title: this.title,
193
+ attributes: { ...this.attributes, lang: pseudoLocale },
194
+ notes: this.notes.length > 0 ? this.notes : void 0,
195
+ messages: []
196
+ };
197
+ this.forEach((msg) => {
198
+ pseudolocalizedData.messages.push({
199
+ key: msg.key,
200
+ value: this.pseudoLocalizeMF2(msg.value),
201
+ attributes: { ...this.attributes, lang: pseudoLocale }
202
+ });
203
+ });
204
+ return this.translate(pseudolocalizedData);
205
+ }
206
+ const languageChain = project.getTargetLocale(lang);
207
+ if (!languageChain) {
208
+ throw new Error("Unsupported locale for resource.");
209
+ }
210
+ if (languageChain.length == 0) {
211
+ throw new Error(`Empty language chain for locale: ${lang}`);
212
+ }
213
+ let translated = this;
214
+ for (let i = 0; i < languageChain.length; i++) {
215
+ const lang2 = languageChain[i];
216
+ if (lang2 && project._locales.targetLocales[lang2]) {
217
+ translated = await translated._project._loader(project.project.name, translated.title, lang2).then((data) => translated.translate(data));
218
+ }
219
+ }
220
+ return translated;
221
+ }
222
+ /**
223
+ * Returns a plain data object for this resource and its messages.
224
+ *
225
+ * Attributes that match the resource or project defaults are omitted where
226
+ * possible to keep the output compact.
227
+ *
228
+ * @param stripNotes - When true, notes are omitted from the result.
229
+ */
230
+ getData(stripNotes = false) {
231
+ const resourceFormat = this.resolveFormat(this.attributes);
232
+ const projectFormat = this._project.format;
233
+ const messages = [];
234
+ this.forEach((msg) => {
235
+ if (this.hasMatchingAttributes(msg)) {
236
+ const data = {
237
+ key: msg.key,
238
+ value: msg.value,
239
+ notes: !stripNotes && msg.notes.length > 0 ? msg.notes : void 0
240
+ };
241
+ messages.push(data);
242
+ } else {
243
+ const data = msg.getData(stripNotes);
244
+ if (data.attributes && this.resolveFormat(data.attributes) === resourceFormat) {
245
+ const { format, ...rest } = data.attributes;
246
+ data.attributes = rest;
247
+ }
248
+ messages.push(data);
249
+ }
250
+ });
251
+ const attributes = { ...this.attributes };
252
+ if (this.resolveFormat(attributes) === projectFormat) {
253
+ delete attributes.format;
254
+ }
255
+ return {
256
+ title: this.title,
257
+ attributes,
258
+ notes: !stripNotes && this.notes.length > 0 ? this.notes : void 0,
259
+ messages
260
+ };
261
+ }
262
+ /**
263
+ * Serializes this resource to a formatted JSON string.
264
+ *
265
+ * @param stripNotes - When true, notes are omitted from the serialized data.
266
+ */
267
+ toJSON(stripNotes = false) {
268
+ return JSON.stringify(this.getData(stripNotes), null, 2);
269
+ }
270
+ };
271
+
272
+ export {
273
+ MsgResource
274
+ };
File without changes
@@ -0,0 +1,13 @@
1
+ // src/lib/lang-utils.ts
2
+ var lang;
3
+ function setLang(tag) {
4
+ lang = tag;
5
+ }
6
+ function getLang() {
7
+ return lang;
8
+ }
9
+
10
+ export {
11
+ setLang,
12
+ getLang
13
+ };
@@ -0,0 +1,12 @@
1
+ // src/classes/MsgInterface/MsgInterface.ts
2
+ var MSG_DEFAULT_FORMAT = "MF2";
3
+ var DEFAULT_ATTRIBUTES = {
4
+ lang: "und",
5
+ dir: "auto",
6
+ dnt: false
7
+ };
8
+
9
+ export {
10
+ MSG_DEFAULT_FORMAT,
11
+ DEFAULT_ATTRIBUTES
12
+ };
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/classes/MsgInterface/MsgInterface.ts
21
+ var MsgInterface_exports = {};
22
+ __export(MsgInterface_exports, {
23
+ DEFAULT_ATTRIBUTES: () => DEFAULT_ATTRIBUTES,
24
+ MSG_DEFAULT_FORMAT: () => MSG_DEFAULT_FORMAT
25
+ });
26
+ module.exports = __toCommonJS(MsgInterface_exports);
27
+ var MSG_DEFAULT_FORMAT = "MF2";
28
+ var DEFAULT_ATTRIBUTES = {
29
+ lang: "und",
30
+ dir: "auto",
31
+ dnt: false
32
+ };
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ DEFAULT_ATTRIBUTES,
36
+ MSG_DEFAULT_FORMAT
37
+ });
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Categories of notes that can be attached to a message or resource.
3
+ */
4
+ type NoteTypes = 'DESCRIPTION' | 'AUTHORSHIP' | 'PARAMETERS' | 'CONTEXT' | 'COMMENT';
5
+ /**
6
+ * A free-form note attached to a message or resource for translators and tools.
7
+ */
8
+ type MsgNote = {
9
+ /** What kind of note this is. */
10
+ type: NoteTypes;
11
+ /** The note text. */
12
+ content: string;
13
+ };
14
+ /**
15
+ * The message formatting syntax a string is written in.
16
+ *
17
+ * - `MF1` — ICU MessageFormat 1 (formatted via `@messageformat/icu-messageformat-1`).
18
+ * - `MF2` — Unicode MessageFormat 2 (the default, for backwards compatibility).
19
+ * - `NONE` — not a formatted message; the raw string is returned as-is.
20
+ */
21
+ type MsgFormat = 'MF1' | 'MF2' | 'NONE';
22
+ /**
23
+ * The format applied when a message does not specify (or inherit) one.
24
+ * Kept at MF2 for backwards compatibility.
25
+ */
26
+ declare const MSG_DEFAULT_FORMAT: MsgFormat;
27
+ /**
28
+ * Locale and formatting metadata shared by messages and resources.
29
+ */
30
+ type MsgAttributes = {
31
+ /** BCP 47 language tag for the content (for example, `en` or `zh-Hans`). */
32
+ lang?: string;
33
+ /** Text direction: typically `ltr`, `rtl`, or `auto`. */
34
+ dir?: string;
35
+ /** When true, the content should not be translated (Do Not Translate). */
36
+ dnt?: boolean;
37
+ /** MessageFormat syntax used by the string, if any. */
38
+ format?: MsgFormat;
39
+ };
40
+ /**
41
+ * Default attribute values applied when none are provided.
42
+ */
43
+ declare const DEFAULT_ATTRIBUTES: MsgAttributes;
44
+ /**
45
+ * Shared shape for objects that carry attributes and translator notes.
46
+ */
47
+ interface MsgInterface {
48
+ /** Locale and formatting metadata. */
49
+ attributes: MsgAttributes;
50
+ /** Notes for translators and tooling. */
51
+ notes: MsgNote[];
52
+ }
53
+
54
+ export { DEFAULT_ATTRIBUTES, MSG_DEFAULT_FORMAT, type MsgAttributes, type MsgFormat, type MsgInterface, type MsgNote, type NoteTypes };
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Categories of notes that can be attached to a message or resource.
3
+ */
4
+ type NoteTypes = 'DESCRIPTION' | 'AUTHORSHIP' | 'PARAMETERS' | 'CONTEXT' | 'COMMENT';
5
+ /**
6
+ * A free-form note attached to a message or resource for translators and tools.
7
+ */
8
+ type MsgNote = {
9
+ /** What kind of note this is. */
10
+ type: NoteTypes;
11
+ /** The note text. */
12
+ content: string;
13
+ };
14
+ /**
15
+ * The message formatting syntax a string is written in.
16
+ *
17
+ * - `MF1` — ICU MessageFormat 1 (formatted via `@messageformat/icu-messageformat-1`).
18
+ * - `MF2` — Unicode MessageFormat 2 (the default, for backwards compatibility).
19
+ * - `NONE` — not a formatted message; the raw string is returned as-is.
20
+ */
21
+ type MsgFormat = 'MF1' | 'MF2' | 'NONE';
22
+ /**
23
+ * The format applied when a message does not specify (or inherit) one.
24
+ * Kept at MF2 for backwards compatibility.
25
+ */
26
+ declare const MSG_DEFAULT_FORMAT: MsgFormat;
27
+ /**
28
+ * Locale and formatting metadata shared by messages and resources.
29
+ */
30
+ type MsgAttributes = {
31
+ /** BCP 47 language tag for the content (for example, `en` or `zh-Hans`). */
32
+ lang?: string;
33
+ /** Text direction: typically `ltr`, `rtl`, or `auto`. */
34
+ dir?: string;
35
+ /** When true, the content should not be translated (Do Not Translate). */
36
+ dnt?: boolean;
37
+ /** MessageFormat syntax used by the string, if any. */
38
+ format?: MsgFormat;
39
+ };
40
+ /**
41
+ * Default attribute values applied when none are provided.
42
+ */
43
+ declare const DEFAULT_ATTRIBUTES: MsgAttributes;
44
+ /**
45
+ * Shared shape for objects that carry attributes and translator notes.
46
+ */
47
+ interface MsgInterface {
48
+ /** Locale and formatting metadata. */
49
+ attributes: MsgAttributes;
50
+ /** Notes for translators and tooling. */
51
+ notes: MsgNote[];
52
+ }
53
+
54
+ export { DEFAULT_ATTRIBUTES, MSG_DEFAULT_FORMAT, type MsgAttributes, type MsgFormat, type MsgInterface, type MsgNote, type NoteTypes };
@@ -0,0 +1,8 @@
1
+ import {
2
+ DEFAULT_ATTRIBUTES,
3
+ MSG_DEFAULT_FORMAT
4
+ } from "../../chunk-XQVALCKX.mjs";
5
+ export {
6
+ DEFAULT_ATTRIBUTES,
7
+ MSG_DEFAULT_FORMAT
8
+ };