@worldware/msg 0.0.1

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 (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +235 -0
  3. package/dist/classes/MsgInterface/MsgInterface.d.ts +17 -0
  4. package/dist/classes/MsgInterface/MsgInterface.d.ts.map +1 -0
  5. package/dist/classes/MsgInterface/MsgInterface.js +6 -0
  6. package/dist/classes/MsgInterface/MsgInterface.js.map +1 -0
  7. package/dist/classes/MsgInterface/index.d.ts +2 -0
  8. package/dist/classes/MsgInterface/index.d.ts.map +1 -0
  9. package/dist/classes/MsgInterface/index.js +2 -0
  10. package/dist/classes/MsgInterface/index.js.map +1 -0
  11. package/dist/classes/MsgMessage/MsgMessage.d.ts +36 -0
  12. package/dist/classes/MsgMessage/MsgMessage.d.ts.map +1 -0
  13. package/dist/classes/MsgMessage/MsgMessage.js +79 -0
  14. package/dist/classes/MsgMessage/MsgMessage.js.map +1 -0
  15. package/dist/classes/MsgMessage/index.d.ts +2 -0
  16. package/dist/classes/MsgMessage/index.d.ts.map +1 -0
  17. package/dist/classes/MsgMessage/index.js +2 -0
  18. package/dist/classes/MsgMessage/index.js.map +1 -0
  19. package/dist/classes/MsgProject/MsgProject.d.ts +36 -0
  20. package/dist/classes/MsgProject/MsgProject.d.ts.map +1 -0
  21. package/dist/classes/MsgProject/MsgProject.js +43 -0
  22. package/dist/classes/MsgProject/MsgProject.js.map +1 -0
  23. package/dist/classes/MsgProject/index.d.ts +2 -0
  24. package/dist/classes/MsgProject/index.d.ts.map +1 -0
  25. package/dist/classes/MsgProject/index.js +2 -0
  26. package/dist/classes/MsgProject/index.js.map +1 -0
  27. package/dist/classes/MsgResource/MsgResource.d.ts +30 -0
  28. package/dist/classes/MsgResource/MsgResource.d.ts.map +1 -0
  29. package/dist/classes/MsgResource/MsgResource.js +109 -0
  30. package/dist/classes/MsgResource/MsgResource.js.map +1 -0
  31. package/dist/classes/MsgResource/index.d.ts +2 -0
  32. package/dist/classes/MsgResource/index.d.ts.map +1 -0
  33. package/dist/classes/MsgResource/index.js +2 -0
  34. package/dist/classes/MsgResource/index.js.map +1 -0
  35. package/dist/classes/index.d.ts +4 -0
  36. package/dist/classes/index.d.ts.map +1 -0
  37. package/dist/classes/index.js +4 -0
  38. package/dist/classes/index.js.map +1 -0
  39. package/dist/index.d.ts +2 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +2 -0
  42. package/dist/index.js.map +1 -0
  43. package/package.json +26 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Joel Sahleen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,235 @@
1
+ # msg
2
+
3
+ A TypeScript library for managing internationalization (i18n) messages with support for message formatting, translation management, and localization workflows.
4
+
5
+ ## Overview
6
+
7
+ `msg` provides a structured approach to managing translatable messages in your application. It integrates with [MessageFormat 2](https://messageformat.github.io/messageformat/) (MF2) for advanced message formatting and supports:
8
+
9
+ - **Message Management**: Organize messages into resources with keys and values
10
+ - **Translation Loading**: Load translations from external sources via customizable loaders
11
+ - **Message Formatting**: Format messages with parameters using MessageFormat 2 (MF2) syntax
12
+ - **Attributes & Notes**: Attach metadata (language, direction, do-not-translate flags) and notes to messages
13
+ - **Project Configuration**: Configure projects with locale settings, paths, and translation loaders
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @worldware/msg
19
+ ```
20
+
21
+ ## Core Concepts
22
+
23
+ ### MsgProject
24
+
25
+ A project configuration that defines:
26
+ - Project name and version
27
+ - Source and target locales
28
+ - File paths for resources and translations
29
+ - A translation loader function
30
+
31
+ ### MsgResource
32
+
33
+ A collection of messages (extends `Map<string, MsgMessage>`) representing a resource bundle. Each resource has:
34
+ - A title/name
35
+ - Attributes (language, text direction, do-not-translate flag)
36
+ - Notes (descriptions, context, etc.)
37
+ - Messages indexed by key
38
+
39
+ ### MsgMessage
40
+
41
+ An individual message with:
42
+ - A key (identifier)
43
+ - A value (the message text, supports MessageFormat 2 (MF2) syntax)
44
+ - Attributes (lang, dir, dnt)
45
+ - Notes
46
+ - Formatting methods using MessageFormat 2
47
+
48
+ ## Usage
49
+
50
+ ### Basic Setup
51
+
52
+ ```typescript
53
+ import { MsgProject, MsgResource } from '@msg';
54
+
55
+ // Create a project configuration
56
+ const project = MsgProject.create({
57
+ project: {
58
+ name: 'my-app',
59
+ version: 1
60
+ },
61
+ locales: {
62
+ sourceLocale: 'en',
63
+ targetLocales: ['en', 'es', 'fr'],
64
+ pseudoLocale: 'zxx'
65
+ },
66
+ paths: {
67
+ srcPaths: ['./src'],
68
+ exportsPath: './xliff/exports',
69
+ importPath: './xliff/imports'
70
+ },
71
+ loader: async (project, title, lang) => {
72
+ // Custom loader to fetch translation data
73
+ const path = `./translations/${project}/${lang}/${title}.json`;
74
+ const data = await import(path);
75
+ return data;
76
+ }
77
+ });
78
+ ```
79
+
80
+ ### Creating a Resource
81
+
82
+ ```typescript
83
+ // Create a resource with messages
84
+ const resource = MsgResource.create({
85
+ title: 'CommonMessages',
86
+ attributes: {
87
+ lang: 'en',
88
+ dir: 'ltr'
89
+ },
90
+ messages: [
91
+ {
92
+ key: 'greeting',
93
+ value: 'Hello, {name}!'
94
+ },
95
+ {
96
+ key: 'welcome',
97
+ value: 'Welcome to our application'
98
+ }
99
+ ]
100
+ }, project);
101
+
102
+ // Or add messages programmatically
103
+ resource.add('goodbye', 'Goodbye, {name}!', {
104
+ lang: 'en',
105
+ dir: 'ltr'
106
+ });
107
+ ```
108
+
109
+ ### Formatting Messages
110
+
111
+ ```typescript
112
+ // Get a message and format it
113
+ const greetingMsg = resource.get('greeting');
114
+ const formatted = greetingMsg?.format({ name: 'Alice' });
115
+ // Result: "Hello, Alice!"
116
+ ```
117
+
118
+ ### Loading Translations
119
+
120
+ ```typescript
121
+ // Load a translation for a specific language
122
+ const spanishResource = await resource.getTranslation('es');
123
+
124
+ // The translated resource will have Spanish messages where available,
125
+ // falling back to the source messages for missing translations
126
+ ```
127
+
128
+ ### Working with Attributes and Notes
129
+
130
+ ```typescript
131
+ // Add notes to messages
132
+ resource.add('complex-message', 'This is a complex message', {
133
+ lang: 'en',
134
+ dir: 'ltr',
135
+ dnt: false // do-not-translate flag
136
+ }, [
137
+ {
138
+ type: 'DESCRIPTION',
139
+ content: 'This message appears on the welcome screen'
140
+ },
141
+ {
142
+ type: 'CONTEXT',
143
+ content: 'Used when user first logs in'
144
+ }
145
+ ]);
146
+
147
+ // Access attributes
148
+ const message = resource.get('complex-message');
149
+ console.log(message?.lang); // 'en'
150
+ console.log(message?.dir); // 'ltr'
151
+ console.log(message?.dnt); // false
152
+ ```
153
+
154
+ ### Serialization
155
+
156
+ ```typescript
157
+ // Convert resource to JSON
158
+ const json = resource.toJSON();
159
+ // or without notes
160
+ const jsonWithoutNotes = resource.toJSON(true);
161
+
162
+ // Get data object
163
+ const data = resource.getData();
164
+ ```
165
+
166
+ ## API Reference
167
+
168
+ ### MsgProject
169
+
170
+ **Static Methods:**
171
+ - `create(data: MsgProjectData): MsgProject` - Create a new project instance
172
+
173
+ **Properties:**
174
+ - `project: MsgProjectSettings` - Project name and version
175
+ - `locales: MsgLocalesSettings` - Locale configuration
176
+ - `paths: MsgPathsSettings` - File path configuration
177
+ - `loader: MsgTranslationLoader` - Translation loader function
178
+
179
+ ### MsgResource
180
+
181
+ **Static Methods:**
182
+ - `create(data: MsgResourceData, project: MsgProject): MsgResource` - Create a new resource
183
+
184
+ **Methods:**
185
+ - `add(key: string, value: string, attributes?: MsgAttributes, notes?: MsgNote[]): MsgResource` - Add a message
186
+ - `translate(data: MsgResourceData): MsgResource` - Create a translated version
187
+ - `getTranslation(lang: string): Promise<MsgResource>` - Load and apply translations
188
+ - `getData(stripNotes?: boolean): MsgResourceData` - Get resource data
189
+ - `toJSON(stripNotes?: boolean): string` - Serialize to JSON
190
+
191
+ **Properties:**
192
+ - `title: string` - Resource title
193
+ - `attributes: MsgAttributes` - Resource attributes
194
+ - `notes: MsgNote[]` - Resource notes
195
+
196
+ ### MsgMessage
197
+
198
+ **Static Methods:**
199
+ - `create(data: MsgMessageData): MsgMessage` - Create a new message
200
+
201
+ **Methods:**
202
+ - `format(data: Record<string, any>, options?: MessageFormatOptions): string` - Format the message
203
+ - `formatToParts(data: Record<string, any>, options?: MessageFormatOptions): MessagePart[]` - Format to parts
204
+ - `addNote(note: MsgNote): void` - Add a note
205
+ - `getData(stripNotes?: boolean): MsgMessageData` - Get message data
206
+ - `toJSON(stripNotes?: boolean): string` - Serialize to JSON
207
+
208
+ **Properties:**
209
+ - `key: string` - Message key
210
+ - `value: string` - Message value
211
+ - `attributes: MsgAttributes` - Message attributes
212
+ - `lang: string` - Language code
213
+ - `dir: string` - Text direction
214
+ - `dnt: boolean` - Do-not-translate flag
215
+ - `notes: MsgNote[]` - Message notes
216
+
217
+ ## Development
218
+
219
+ ```bash
220
+ # Run tests
221
+ npm test
222
+
223
+ # Run tests in watch mode
224
+ npm run test:watch
225
+
226
+ # Run tests with coverage
227
+ npm run coverage
228
+
229
+ # Build the project
230
+ npm run build
231
+ ```
232
+
233
+ ## License
234
+
235
+ See LICENSE file for details.
@@ -0,0 +1,17 @@
1
+ type NoteTypes = 'DESCRIPTION' | 'AUTHORSHIP' | 'PARAMETERS' | 'CONTEXT' | 'COMMENT';
2
+ export type MsgNote = {
3
+ type: NoteTypes;
4
+ content: string;
5
+ };
6
+ export type MsgAttributes = {
7
+ lang?: string;
8
+ dir?: string;
9
+ dnt?: boolean;
10
+ };
11
+ export declare const DEFAULT_ATTRIBUTES: MsgAttributes;
12
+ export interface MsgInterface {
13
+ attributes: MsgAttributes;
14
+ notes: MsgNote[];
15
+ }
16
+ export {};
17
+ //# sourceMappingURL=MsgInterface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MsgInterface.d.ts","sourceRoot":"","sources":["../../../src/classes/MsgInterface/MsgInterface.ts"],"names":[],"mappings":"AAAA,KAAK,SAAS,GAAI,aAAa,GAAG,YAAY,GAAG,YAAY,GAAG,SAAS,GAAG,SAAS,CAAC;AAEtF,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,SAAS,CAAA;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,OAAO,CAAA;CACd,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,aAIhC,CAAA;AAID,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,aAAa,CAAA;IACzB,KAAK,EAAE,OAAO,EAAE,CAAA;CACjB"}
@@ -0,0 +1,6 @@
1
+ export const DEFAULT_ATTRIBUTES = {
2
+ lang: '',
3
+ dir: '',
4
+ dnt: false
5
+ };
6
+ //# sourceMappingURL=MsgInterface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MsgInterface.js","sourceRoot":"","sources":["../../../src/classes/MsgInterface/MsgInterface.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,MAAM,kBAAkB,GAAkB;IAC/C,IAAI,EAAE,EAAE;IACR,GAAG,EAAE,EAAE;IACP,GAAG,EAAE,KAAK;CACX,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './MsgInterface';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/classes/MsgInterface/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './MsgInterface';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/classes/MsgInterface/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { type MessageFormatOptions } from "messageformat";
2
+ import { MsgInterface, type MsgAttributes, type MsgNote } from "../MsgInterface";
3
+ export type MsgMessageData = {
4
+ key: string;
5
+ value: string;
6
+ attributes?: MsgAttributes;
7
+ notes?: MsgNote[];
8
+ };
9
+ export declare class MsgMessage implements MsgInterface {
10
+ private _key;
11
+ private _value;
12
+ private _mf?;
13
+ private _attributes;
14
+ private _notes;
15
+ private constructor();
16
+ static create(data: MsgMessageData): MsgMessage;
17
+ get key(): string;
18
+ get value(): string;
19
+ get attributes(): MsgAttributes;
20
+ get lang(): string | undefined;
21
+ get dir(): string | undefined;
22
+ get dnt(): boolean | undefined;
23
+ get notes(): MsgNote[];
24
+ addNote(note: MsgNote): void;
25
+ format(data: Record<string, any>, options?: MessageFormatOptions): any;
26
+ formatToParts(data: Record<string, any>, options?: MessageFormatOptions): any;
27
+ getData(stripNotes?: boolean): {
28
+ key: string;
29
+ value: string;
30
+ attributes: MsgAttributes;
31
+ notes: MsgNote[] | undefined;
32
+ };
33
+ toString(): string;
34
+ toJSON(stripNotes?: boolean): string;
35
+ }
36
+ //# sourceMappingURL=MsgMessage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MsgMessage.d.ts","sourceRoot":"","sources":["../../../src/classes/MsgMessage/MsgMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAAE,KAAK,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAEjF,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,KAAK,CAAC,EAAE,OAAO,EAAE,CAAA;CAClB,CAAA;AAQD,qBAAa,UAAW,YAAW,YAAY;IAC7C,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,GAAG,CAAC,CAAgB;IAC5B,OAAO,CAAC,WAAW,CAAqC;IACxD,OAAO,CAAC,MAAM,CAAiB;IAE/B,OAAO;IAcP,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc;IAMlC,IAAW,GAAG,WAEb;IAED,IAAW,KAAK,WAEf;IAED,IAAW,UAAU,kBAEpB;IAED,IAAW,IAAI,uBAEd;IAED,IAAW,GAAG,uBAEb;IAED,IAAW,GAAG,wBAEb;IAED,IAAW,KAAK,cAEf;IAEM,OAAO,CAAC,IAAI,EAAE,OAAO;IAIrB,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,EAAE,oBAAoB;IAOhE,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,EAAE,oBAAoB;IAOvE,OAAO,CAAC,UAAU,GAAE,OAAe;;;;;;IASnC,QAAQ;IAIR,MAAM,CAAC,UAAU,GAAE,OAAe;CAI1C"}
@@ -0,0 +1,79 @@
1
+ import { MessageFormat } from "messageformat";
2
+ const DEFAULT_ATTRIBUTES = {
3
+ lang: "",
4
+ dir: "",
5
+ dnt: false
6
+ };
7
+ export class MsgMessage {
8
+ _key;
9
+ _value;
10
+ _mf;
11
+ _attributes = DEFAULT_ATTRIBUTES;
12
+ _notes = [];
13
+ constructor(key, value, attributes, notes) {
14
+ this._key = key;
15
+ this._value = value;
16
+ // merge in any attributes
17
+ this._attributes = attributes ? { ...this._attributes, ...attributes } : this._attributes;
18
+ // add any notes
19
+ if (notes) {
20
+ notes.forEach(note => this.addNote(note));
21
+ }
22
+ }
23
+ static create(data) {
24
+ const { key, value, attributes, notes } = data;
25
+ const message = new MsgMessage(key, value, attributes, notes);
26
+ return message;
27
+ }
28
+ get key() {
29
+ return this._key;
30
+ }
31
+ get value() {
32
+ return this._value;
33
+ }
34
+ get attributes() {
35
+ return this._attributes;
36
+ }
37
+ get lang() {
38
+ return this._attributes['lang'];
39
+ }
40
+ get dir() {
41
+ return this._attributes['dir'];
42
+ }
43
+ get dnt() {
44
+ return this._attributes['dnt'];
45
+ }
46
+ get notes() {
47
+ return this._notes;
48
+ }
49
+ addNote(note) {
50
+ this.notes.push(note);
51
+ }
52
+ format(data, options) {
53
+ if (!this._mf) {
54
+ this._mf = new MessageFormat(this.lang, this.value, options);
55
+ }
56
+ return this._mf.format(data);
57
+ }
58
+ formatToParts(data, options) {
59
+ if (!this._mf) {
60
+ this._mf = new MessageFormat(this.lang, this.value, options);
61
+ }
62
+ return this._mf?.formatToParts(data);
63
+ }
64
+ getData(stripNotes = false) {
65
+ return {
66
+ key: this.key,
67
+ value: this.value,
68
+ attributes: this.attributes,
69
+ notes: !stripNotes && this.notes.length > 0 ? this.notes : undefined
70
+ };
71
+ }
72
+ toString() {
73
+ return this.value;
74
+ }
75
+ toJSON(stripNotes = false) {
76
+ return JSON.stringify(this.getData(stripNotes), null, 2);
77
+ }
78
+ }
79
+ //# sourceMappingURL=MsgMessage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MsgMessage.js","sourceRoot":"","sources":["../../../src/classes/MsgMessage/MsgMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA6B,MAAM,eAAe,CAAC;AAUzE,MAAM,kBAAkB,GAAkB;IACxC,IAAI,EAAE,EAAE;IACR,GAAG,EAAE,EAAE;IACP,GAAG,EAAE,KAAK;CACX,CAAA;AAED,MAAM,OAAO,UAAU;IACb,IAAI,CAAS;IACb,MAAM,CAAS;IACf,GAAG,CAAiB;IACpB,WAAW,GAAkB,kBAAkB,CAAC;IAChD,MAAM,GAAc,EAAE,CAAC;IAE/B,YAAoB,GAAW,EAAE,KAAa,EAAE,UAA0B,EAAE,KAAiB;QAC3F,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QAEpB,0BAA0B;QAC1B,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,CAAC,CAAC,EAAC,GAAG,IAAI,CAAC,WAAW,EAAE,GAAG,UAAU,EAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC;QAExF,gBAAgB;QAChB,IAAI,KAAK,EAAE;YACT,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;SAC3C;IAEH,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,IAAoB;QAChC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QAC/C,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;QAC9D,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,IAAW,GAAG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,EAAE,IAAI,CAAC,KAAK;YACjB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,KAAK,EAAE,CAAC,UAAU,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;SACrE,CAAA;IACH,CAAC;IAEM,QAAQ;QACb,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAEM,MAAM,CAAC,aAAsB,KAAK;QACvC,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC;CAEF"}
@@ -0,0 +1,2 @@
1
+ export * from './MsgMessage';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/classes/MsgMessage/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './MsgMessage';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/classes/MsgMessage/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { type MsgResourceData } from "../MsgResource";
2
+ type MsgProjectSettings = {
3
+ name: string;
4
+ version?: number;
5
+ };
6
+ type MsgLocalesSettings = {
7
+ sourceLocale: string;
8
+ pseudoLocale?: string;
9
+ targetLocales?: string[];
10
+ };
11
+ type MsgPathsSettings = {
12
+ srcPaths?: string[];
13
+ exportsPath?: string;
14
+ importPath?: string;
15
+ };
16
+ export type MsgTranslationLoader = (project: string, title: string, lang: string) => Promise<MsgResourceData>;
17
+ export type MsgProjectData = {
18
+ project: MsgProjectSettings;
19
+ locales: MsgLocalesSettings;
20
+ paths: MsgPathsSettings;
21
+ loader: MsgTranslationLoader;
22
+ };
23
+ export declare class MsgProject {
24
+ _project: MsgProjectSettings;
25
+ _locales: MsgLocalesSettings;
26
+ _paths: MsgPathsSettings;
27
+ _loader: MsgTranslationLoader;
28
+ static create(data: MsgProjectData): MsgProject;
29
+ private constructor();
30
+ get project(): MsgProjectSettings;
31
+ get locales(): MsgLocalesSettings;
32
+ get paths(): MsgPathsSettings;
33
+ get loader(): MsgTranslationLoader;
34
+ }
35
+ export {};
36
+ //# sourceMappingURL=MsgProject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MsgProject.d.ts","sourceRoot":"","sources":["../../../src/classes/MsgProject/MsgProject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD,KAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;CACzB,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACtB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;AAE9G,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,kBAAkB,CAAA;IAC3B,OAAO,EAAE,kBAAkB,CAAA;IAC3B,KAAK,EAAE,gBAAgB,CAAA;IACvB,MAAM,EAAE,oBAAoB,CAAA;CAC7B,CAAC;AAmBF,qBAAa,UAAU;IACrB,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,MAAM,EAAE,gBAAgB,CAAC;IACzB,OAAO,EAAE,oBAAoB,CAAC;IAE9B,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc;IAKlC,OAAO;IAYP,IAAW,OAAO,uBAEjB;IAED,IAAW,OAAO,uBAEjB;IAED,IAAW,KAAK,qBAEf;IAED,IAAW,MAAM,yBAEhB;CACF"}
@@ -0,0 +1,43 @@
1
+ const defaultProjectSettings = {
2
+ name: 'messages',
3
+ version: 1
4
+ };
5
+ const defaultLocalesSettings = {
6
+ sourceLocale: '',
7
+ pseudoLocale: 'zxx',
8
+ targetLocales: ['']
9
+ };
10
+ const defaultPathsSettings = {
11
+ srcPaths: ['../../../src'],
12
+ exportsPath: '../xliff/exports',
13
+ importPath: '../xliff/imports'
14
+ };
15
+ export class MsgProject {
16
+ _project;
17
+ _locales;
18
+ _paths;
19
+ _loader;
20
+ static create(data) {
21
+ const { project, locales, paths, loader } = data;
22
+ return new MsgProject(project, locales, paths, loader);
23
+ }
24
+ constructor(projectSettings, localesSettings, pathsSettings, loader) {
25
+ this._project = { ...defaultProjectSettings, ...projectSettings };
26
+ this._locales = { ...defaultLocalesSettings, ...localesSettings };
27
+ this._paths = { ...defaultPathsSettings, ...pathsSettings };
28
+ this._loader = loader;
29
+ }
30
+ get project() {
31
+ return this._project;
32
+ }
33
+ get locales() {
34
+ return this._locales;
35
+ }
36
+ get paths() {
37
+ return this._paths;
38
+ }
39
+ get loader() {
40
+ return this._loader;
41
+ }
42
+ }
43
+ //# sourceMappingURL=MsgProject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MsgProject.js","sourceRoot":"","sources":["../../../src/classes/MsgProject/MsgProject.ts"],"names":[],"mappings":"AA4BA,MAAM,sBAAsB,GAAuB;IACjD,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,CAAC;CACX,CAAC;AAEF,MAAM,sBAAsB,G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sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/classes/MsgProject/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './MsgProject';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/classes/MsgProject/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { type MsgMessageData, MsgMessage } from "../MsgMessage";
2
+ import { MsgAttributes, MsgInterface, MsgNote } from "../MsgInterface";
3
+ import { MsgProject } from "../MsgProject";
4
+ export type MsgResourceData = {
5
+ title: string;
6
+ attributes: MsgAttributes;
7
+ notes?: MsgNote[];
8
+ messages?: MsgMessageData[];
9
+ };
10
+ export declare class MsgResource extends Map<string, MsgMessage> implements MsgInterface {
11
+ private _attributes;
12
+ private _notes;
13
+ private _title;
14
+ private _project;
15
+ static create(data: MsgResourceData, loader: MsgProject): MsgResource;
16
+ private constructor();
17
+ get attributes(): MsgAttributes;
18
+ set attributes(attributes: MsgAttributes);
19
+ get notes(): MsgNote[];
20
+ set notes(notes: MsgNote[]);
21
+ addNote(note: MsgNote): void;
22
+ get title(): string;
23
+ set title(title: string);
24
+ add(key: string, value: string, attributes?: MsgAttributes, notes?: MsgNote[]): this;
25
+ translate(data: MsgResourceData): MsgResource;
26
+ getTranslation(lang: string): Promise<MsgResource>;
27
+ getData(stripNotes?: boolean): MsgResourceData;
28
+ toJSON(stripNotes?: boolean): string;
29
+ }
30
+ //# sourceMappingURL=MsgResource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MsgResource.d.ts","sourceRoot":"","sources":["../../../src/classes/MsgResource/MsgResource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,cAAc,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC/D,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Message } from "../MsgMessage";
2
+ import { DEFAULT_ATTRIBUTES } from "../MsgInterface";
3
+ export class MsgResource extends Map {
4
+ _attributes = DEFAULT_ATTRIBUTES;
5
+ _notes = [];
6
+ _title;
7
+ _project;
8
+ static create(data, loader) {
9
+ const { title, attributes, notes, messages } = data;
10
+ const res = new MsgResource(title, attributes, loader, notes);
11
+ if (messages) {
12
+ messages.forEach(messageData => {
13
+ const { key, value, attributes, notes } = messageData;
14
+ res.add(key, value, attributes, notes);
15
+ });
16
+ }
17
+ else {
18
+ res.clear();
19
+ }
20
+ return res;
21
+ }
22
+ constructor(title, attributes, project, notes) {
23
+ super();
24
+ this._title = title;
25
+ this._attributes = { ...this._attributes, ...attributes };
26
+ this._project = project;
27
+ if (notes) {
28
+ notes.forEach(note => this.addNote(note));
29
+ }
30
+ }
31
+ get attributes() {
32
+ return this._attributes;
33
+ }
34
+ set attributes(attributes) {
35
+ this._attributes = attributes;
36
+ }
37
+ get notes() {
38
+ return this._notes;
39
+ }
40
+ set notes(notes) {
41
+ this._notes = notes;
42
+ }
43
+ addNote(note) {
44
+ this.notes.push(note);
45
+ }
46
+ get title() {
47
+ return this._title;
48
+ }
49
+ set title(title) {
50
+ this._title = title;
51
+ }
52
+ add(key, value, attributes, notes) {
53
+ const merged = { ...this.attributes, ...attributes };
54
+ const msg = MsgMessage.create({
55
+ key,
56
+ value,
57
+ attributes: merged,
58
+ notes
59
+ });
60
+ this.set(key, msg);
61
+ return this;
62
+ }
63
+ translate(data) {
64
+ const { title, attributes, messages } = data;
65
+ if (title !== this.title) {
66
+ throw new TypeError('Title of resource and translations do not match.');
67
+ }
68
+ const translated = MsgResource.create({
69
+ title,
70
+ attributes,
71
+ notes: this.notes, // transfer the notes
72
+ }, this._project);
73
+ // use messages from the resource as defaults
74
+ this.forEach(msg => {
75
+ translated.set(msg.key, msg);
76
+ });
77
+ messages?.forEach(messageData => {
78
+ const { key, value, attributes } = messageData;
79
+ const msg = MsgMessage.create({
80
+ key,
81
+ value,
82
+ attributes,
83
+ });
84
+ const notes = this.get(key)?.notes || []; // transfer the notes
85
+ notes.forEach(note => {
86
+ msg.addNote(note);
87
+ });
88
+ translated.set(key, msg);
89
+ });
90
+ return translated;
91
+ }
92
+ async getTranslation(lang) {
93
+ return await this._project.loader(this._project.project.name, this.title, lang).then((data) => this.translate(data));
94
+ }
95
+ getData(stripNotes = false) {
96
+ const messages = [];
97
+ this.forEach(msg => messages.push(msg.getData(stripNotes)));
98
+ return {
99
+ title: this.title,
100
+ attributes: this.attributes,
101
+ notes: !stripNotes && this.notes.length > 0 ? this.notes : undefined,
102
+ messages
103
+ };
104
+ }
105
+ toJSON(stripNotes = false) {
106
+ return JSON.stringify(this.getData(stripNotes), null, 2);
107
+ }
108
+ }
109
+ //# sourceMappingURL=MsgResource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MsgResource.js","sourceRoot":"","sources":["../../../src/classes/MsgResource/MsgResource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,UAAU,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAwC,MAAM,iBAAiB,CAAC;AAU3F,MAAM,OAAO,WAAY,SAAQ,GAAuB;IAE9C,WAAW,GAAkB,kBAAkB,CAAC;IAChD,MAAM,GAAc,EAAE,CAAC;IACvB,MAAM,CAAS;IAEf,QAAQ,CAAa;IAE7B,MAAM,CAAC,MAAM,CAAC,IAAqB,EAAE,MAAkB;QACrD,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAC,GAAI,IAAI,CAAC;QACpD,MAAM,GAAG,GAAG,IAAI,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QAE9D,IAAI,QAAQ,EAAE;YACZ,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;gBAC7B,MAAM,EAAC,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAC,GAAG,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,CAAC,CAAC;YACpB,CAAC,CAAC,CAAA;YACF,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAA;QAEF,OAAO,UAAU,CAAC;IACpB,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,IAAY;QACtC,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IACvH,CAAC;IAEM,OAAO,CAAC,aAAsB,KAAK;QAExC,MAAM,QAAQ,GAAqB,EAAE,CAAC;QACtC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;QAE3D,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,KAAK,EAAE,CAAC,UAAU,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;YACpE,QAAQ;SACT,CAAA;IACH,CAAC;IAEM,MAAM,CAAC,aAAsB,KAAK;QACvC,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC;CAEF"}
@@ -0,0 +1,2 @@
1
+ export * from './MsgResource';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/classes/MsgResource/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './MsgResource';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/classes/MsgResource/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './MsgMessage';
2
+ export * from './MsgResource';
3
+ export * from './MsgProject';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/classes/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './MsgMessage';
2
+ export * from './MsgResource';
3
+ export * from './MsgProject';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/classes/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './classes';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './classes';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@worldware/msg",
3
+ "version": "0.0.1",
4
+ "description": "Message localization tooling",
5
+ "main": "dist/index.js",
6
+ "type": "module",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "devDependencies": {
12
+ "@types/typescript": "^0.4.29",
13
+ "@vitest/coverage-v8": "^4.0.15",
14
+ "typescript": "^5.9.3",
15
+ "vitest": "^4.0.15"
16
+ },
17
+ "dependencies": {
18
+ "messageformat": "4.0.0-10"
19
+ },
20
+ "scripts": {
21
+ "build": "npm test && tsc",
22
+ "test": "vitest run",
23
+ "test:watch": "vitest",
24
+ "coverage": "vitest run --coverage"
25
+ }
26
+ }