@flyingrobots/bijou-i18n-tools 4.1.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/LICENSE ADDED
@@ -0,0 +1,159 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and
10
+ distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright
13
+ owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other entities
16
+ that control, are controlled by, or are under common control with that entity.
17
+ For the purposes of this definition, "control" means (i) the power, direct or
18
+ indirect, to cause the direction or management of such entity, whether by
19
+ contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
20
+ outstanding shares, or (iii) beneficial ownership of such entity.
21
+
22
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
23
+ permissions granted by this License.
24
+
25
+ "Source" form shall mean the preferred form for making modifications, including
26
+ but not limited to software source code, documentation source, and configuration
27
+ files.
28
+
29
+ "Object" form shall mean any form resulting from mechanical transformation or
30
+ translation of a Source form, including but not limited to compiled object code,
31
+ generated documentation, and conversions to other media types.
32
+
33
+ "Work" shall mean the work of authorship, whether in Source or Object form, made
34
+ available under the License, as indicated by a copyright notice that is included
35
+ in or attached to the work (an example is provided in the Appendix below).
36
+
37
+ "Derivative Works" shall mean any work, whether in Source or Object form, that
38
+ is based on (or derived from) the Work and for which the editorial revisions,
39
+ annotations, elaborations, or other modifications represent, as a whole, an
40
+ original work of authorship. For the purposes of this License, Derivative Works
41
+ shall not include works that remain separable from, or merely link (or bind by
42
+ name) to the interfaces of, the Work and Derivative Works thereof.
43
+
44
+ "Contribution" shall mean any work of authorship, including the original version
45
+ of the Work and any modifications or additions to that Work or Derivative Works
46
+ thereof, that is intentionally submitted to Licensor for inclusion in the Work
47
+ by the copyright owner or by an individual or Legal Entity authorized to submit
48
+ on behalf of the copyright owner. For the purposes of this definition,
49
+ "submitted" means any form of electronic, verbal, or written communication sent
50
+ to the Licensor or its representatives, including but not limited to
51
+ communication on electronic mailing lists, source code control systems, and
52
+ issue tracking systems that are managed by, or on behalf of, the Licensor for
53
+ the purpose of discussing and improving the Work, but excluding communication
54
+ that is conspicuously marked or otherwise designated in writing by the copyright
55
+ owner as "Not a Contribution."
56
+
57
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
58
+ of whom a Contribution has been received by Licensor and subsequently
59
+ incorporated within the Work.
60
+
61
+ 2. Grant of Copyright License. Subject to the terms and conditions of this
62
+ License, each Contributor hereby grants to You a perpetual, worldwide,
63
+ non-exclusive, no-charge, royalty-free, irrevocable copyright license to
64
+ reproduce, prepare Derivative Works of, publicly display, publicly perform,
65
+ sublicense, and distribute the Work and such Derivative Works in Source or
66
+ Object form.
67
+
68
+ 3. Grant of Patent License. Subject to the terms and conditions of this License,
69
+ each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
70
+ no-charge, royalty-free, irrevocable (except as stated in this section) patent
71
+ license to make, have made, use, offer to sell, sell, import, and otherwise
72
+ transfer the Work, where such license applies only to those patent claims
73
+ licensable by such Contributor that are necessarily infringed by their
74
+ Contribution(s) alone or by combination of their Contribution(s) with the Work
75
+ to which such Contribution(s) was submitted. If You institute patent litigation
76
+ against any entity (including a cross-claim or counterclaim in a lawsuit)
77
+ alleging that the Work or a Contribution incorporated within the Work
78
+ constitutes direct or contributory patent infringement, then any patent licenses
79
+ granted to You under this License for that Work shall terminate as of the date
80
+ such litigation is filed.
81
+
82
+ 4. Redistribution. You may reproduce and distribute copies of the Work or
83
+ Derivative Works thereof in any medium, with or without modifications, and in
84
+ Source or Object form, provided that You meet the following conditions:
85
+
86
+ (a) You must give any other recipients of the Work or Derivative Works a copy of
87
+ this License; and
88
+
89
+ (b) You must cause any modified files to carry prominent notices stating that You
90
+ changed the files; and
91
+
92
+ (c) You must retain, in the Source form of any Derivative Works that You
93
+ distribute, all copyright, patent, trademark, and attribution notices from the
94
+ Source form of the Work, excluding those notices that do not pertain to any part
95
+ of the Derivative Works; and
96
+
97
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then
98
+ any Derivative Works that You distribute must include a readable copy of the
99
+ attribution notices contained within such NOTICE file, excluding those notices
100
+ that do not pertain to any part of the Derivative Works, in at least one of the
101
+ following places: within a NOTICE text file distributed as part of the
102
+ Derivative Works; within the Source form or documentation, if provided along
103
+ with the Derivative Works; or, within a display generated by the Derivative
104
+ Works, if and wherever such third-party notices normally appear. The contents of
105
+ the NOTICE file are for informational purposes only and do not modify the
106
+ License. You may add Your own attribution notices within Derivative Works that
107
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
108
+ provided that such additional attribution notices cannot be construed as
109
+ modifying the License.
110
+
111
+ You may add Your own copyright statement to Your modifications and may provide
112
+ additional or different license terms and conditions for use, reproduction, or
113
+ distribution of Your modifications, or for any such Derivative Works as a whole,
114
+ provided Your use, reproduction, and distribution of the Work otherwise complies
115
+ with the conditions stated in this License.
116
+
117
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any
118
+ Contribution intentionally submitted for inclusion in the Work by You to the
119
+ Licensor shall be under the terms and conditions of this License, without any
120
+ additional terms or conditions. Notwithstanding the above, nothing herein shall
121
+ supersede or modify the terms of any separate license agreement you may have
122
+ executed with Licensor regarding such Contributions.
123
+
124
+ 6. Trademarks. This License does not grant permission to use the trade names,
125
+ trademarks, service marks, or product names of the Licensor, except as required
126
+ for reasonable and customary use in describing the origin of the Work and
127
+ reproducing the content of the NOTICE file.
128
+
129
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
130
+ writing, Licensor provides the Work (and each Contributor provides its
131
+ Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
132
+ KIND, either express or implied, including, without limitation, any warranties
133
+ or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
134
+ PARTICULAR PURPOSE. You are solely responsible for determining the
135
+ appropriateness of using or redistributing the Work and assume any risks
136
+ associated with Your exercise of permissions under this License.
137
+
138
+ 8. Limitation of Liability. In no event and under no legal theory, whether in
139
+ tort (including negligence), contract, or otherwise, unless required by
140
+ applicable law (such as deliberate and grossly negligent acts) or agreed to in
141
+ writing, shall any Contributor be liable to You for damages, including any
142
+ direct, indirect, special, incidental, or consequential damages of any
143
+ character arising as a result of this License or out of the use or inability to
144
+ use the Work (including but not limited to damages for loss of goodwill, work
145
+ stoppage, computer failure or malfunction, or any and all other commercial
146
+ damages or losses), even if such Contributor has been advised of the
147
+ possibility of such damages.
148
+
149
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or
150
+ Derivative Works thereof, You may choose to offer, and charge a fee for,
151
+ acceptance of support, warranty, indemnity, or other liability obligations
152
+ and/or rights consistent with this License. However, in accepting such
153
+ obligations, You may act only on Your own behalf and on Your sole
154
+ responsibility, not on behalf of any other Contributor, and only if You agree to
155
+ indemnify, defend, and hold each Contributor harmless for any liability incurred
156
+ by, or claims asserted against, such Contributor by reason of your accepting any
157
+ such warranty or additional liability.
158
+
159
+ END OF TERMS AND CONDITIONS
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # @flyingrobots/bijou-i18n-tools
2
+
3
+ Workflow and authoring tooling for Bijou localization.
4
+
5
+ `@flyingrobots/bijou-i18n-tools` provides:
6
+
7
+ - authoring catalog types
8
+ - source-hash stale detection
9
+ - provider-neutral tabular export/import rows
10
+ - spreadsheet-friendly workbook export/import
11
+ - CSV/TSV sheet serialization and parsing
12
+ - serializable catalog-bundle export/import
13
+ - JSON bundle serialization and parsing
14
+ - typed value encoding/decoding for strings, data, and refs
15
+ - reference validation and normalization
16
+ - compilation into `@flyingrobots/bijou-i18n` runtime catalogs
17
+ - pseudo-localization helpers
18
+
19
+ This package is intentionally provider-neutral. Filesystem, XLSX, or service-backed adapters can sit on top of it without polluting the core tooling API.
@@ -0,0 +1,7 @@
1
+ import type { CatalogBundle, ExchangeSheet } from './exchange.js';
2
+ export type DelimitedFormat = 'csv' | 'tsv';
3
+ export declare function serializeExchangeSheet(sheet: ExchangeSheet, format: DelimitedFormat): string;
4
+ export declare function parseExchangeSheet(name: string, input: string, format: DelimitedFormat): ExchangeSheet;
5
+ export declare function serializeCatalogBundleJson(bundle: CatalogBundle): string;
6
+ export declare function parseCatalogBundleJson(input: string): CatalogBundle;
7
+ //# sourceMappingURL=adapters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapters.d.ts","sourceRoot":"","sources":["../src/adapters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAA0B,MAAM,eAAe,CAAC;AAG1F,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,KAAK,CAAC;AA4G5C,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,eAAe,GAAG,MAAM,CAa5F;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,eAAe,GACtB,aAAa,CA0Bf;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAExE;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAcnE"}
@@ -0,0 +1,145 @@
1
+ import { exportCatalogBundle, importCatalogBundle } from './exchange.js';
2
+ function delimiterFor(format) {
3
+ return format === 'csv' ? ',' : '\t';
4
+ }
5
+ function escapeCell(value, delimiter) {
6
+ if (!value.includes(delimiter) && !value.includes('"') && !value.includes('\n') && !value.includes('\r')) {
7
+ return value;
8
+ }
9
+ return `"${value.replaceAll('"', '""')}"`;
10
+ }
11
+ function serializeDelimitedRow(values, delimiter) {
12
+ return values.map((value) => escapeCell(value, delimiter)).join(delimiter);
13
+ }
14
+ function parseDelimited(input, delimiter) {
15
+ const rows = [];
16
+ let row = [];
17
+ let cell = '';
18
+ let inQuotes = false;
19
+ for (let index = 0; index < input.length; index += 1) {
20
+ const char = input[index];
21
+ const next = input[index + 1];
22
+ if (inQuotes) {
23
+ if (char === '"') {
24
+ if (next === '"') {
25
+ cell += '"';
26
+ index += 1;
27
+ continue;
28
+ }
29
+ inQuotes = false;
30
+ continue;
31
+ }
32
+ cell += char;
33
+ continue;
34
+ }
35
+ if (char === '"') {
36
+ if (cell.length !== 0) {
37
+ cell += char;
38
+ continue;
39
+ }
40
+ inQuotes = true;
41
+ continue;
42
+ }
43
+ if (char === delimiter) {
44
+ row.push(cell);
45
+ cell = '';
46
+ continue;
47
+ }
48
+ if (char === '\r') {
49
+ continue;
50
+ }
51
+ if (char === '\n') {
52
+ row.push(cell);
53
+ rows.push(row);
54
+ row = [];
55
+ cell = '';
56
+ continue;
57
+ }
58
+ cell += char;
59
+ }
60
+ if (inQuotes) {
61
+ throw new Error('Invalid delimited sheet: unterminated quoted cell');
62
+ }
63
+ if (cell.length > 0 || row.length > 0) {
64
+ row.push(cell);
65
+ rows.push(row);
66
+ }
67
+ return rows;
68
+ }
69
+ function assertWorkbookRow(row, context) {
70
+ const required = [
71
+ 'namespace',
72
+ 'id',
73
+ 'kind',
74
+ 'sourceLocale',
75
+ 'targetLocale',
76
+ 'status',
77
+ 'sourceHash',
78
+ 'description',
79
+ 'sourceValueKind',
80
+ 'sourceValue',
81
+ 'translatedValueKind',
82
+ 'translatedValue',
83
+ ];
84
+ for (const key of required) {
85
+ if (typeof row[key] !== 'string') {
86
+ throw new Error(`Invalid delimited sheet: missing ${key} in ${context}`);
87
+ }
88
+ }
89
+ return row;
90
+ }
91
+ export function serializeExchangeSheet(sheet, format) {
92
+ const delimiter = delimiterFor(format);
93
+ const lines = [
94
+ serializeDelimitedRow(sheet.columns, delimiter),
95
+ ...sheet.rows.map((row) => serializeDelimitedRow(sheet.columns.map((column) => {
96
+ const value = row[column];
97
+ return typeof value === 'string' ? value : '';
98
+ }), delimiter)),
99
+ ];
100
+ return lines.join('\n');
101
+ }
102
+ export function parseExchangeSheet(name, input, format) {
103
+ const delimiter = delimiterFor(format);
104
+ const rows = parseDelimited(input, delimiter);
105
+ if (rows.length === 0) {
106
+ throw new Error(`Invalid delimited sheet: empty ${name}`);
107
+ }
108
+ const [header, ...body] = rows;
109
+ if (header === undefined) {
110
+ throw new Error(`Invalid delimited sheet: missing header in ${name}`);
111
+ }
112
+ const columns = [...header];
113
+ const parsedRows = body.map((cells, rowIndex) => {
114
+ if (cells.length !== columns.length) {
115
+ throw new Error(`Invalid delimited sheet: ragged row ${rowIndex + 2} in ${name}`);
116
+ }
117
+ const record = Object.fromEntries(columns.map((column, index) => [column, cells[index] ?? '']));
118
+ return assertWorkbookRow(record, `${name}:${rowIndex + 2}`);
119
+ });
120
+ return {
121
+ name,
122
+ columns,
123
+ rows: parsedRows,
124
+ };
125
+ }
126
+ export function serializeCatalogBundleJson(bundle) {
127
+ return JSON.stringify(bundle, null, 2);
128
+ }
129
+ export function parseCatalogBundleJson(input) {
130
+ let parsed;
131
+ try {
132
+ parsed = JSON.parse(input);
133
+ }
134
+ catch {
135
+ throw new Error('Invalid catalog bundle json: malformed json');
136
+ }
137
+ try {
138
+ return exportCatalogBundle(importCatalogBundle(parsed));
139
+ }
140
+ catch (error) {
141
+ const message = error instanceof Error ? error.message : 'unknown error';
142
+ throw new Error(`Invalid catalog bundle json: ${message}`);
143
+ }
144
+ }
145
+ //# sourceMappingURL=adapters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapters.js","sourceRoot":"","sources":["../src/adapters.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAIzE,SAAS,YAAY,CAAC,MAAuB;IAC3C,OAAO,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;AACvC,CAAC;AAED,S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AC;IAED,IAAI,CAAC;QACH,OAAO,mBAAmB,CAAC,mBAAmB,CAAC,MAAuB,CAAC,CAAC,CAAC;IAC3E,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;QACzE,MAAM,IAAI,KAAK,CAAC,gCAAgC,OAAO,EAAE,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC"}
@@ -0,0 +1,58 @@
1
+ import type { I18nCatalogKey, I18nEntryKind } from '@flyingrobots/bijou-i18n';
2
+ import type { AuthoringCatalog, AuthoringTranslationStatus, TranslationRow } from './tools.js';
3
+ export type ExchangeValueKind = 'string' | 'number' | 'boolean' | 'null' | 'object' | 'array' | 'reference';
4
+ export interface EncodedExchangeValue {
5
+ readonly kind: ExchangeValueKind;
6
+ readonly payload: string;
7
+ }
8
+ export interface TranslationWorkbookRow {
9
+ readonly namespace: string;
10
+ readonly id: string;
11
+ readonly kind: string;
12
+ readonly sourceLocale: string;
13
+ readonly targetLocale: string;
14
+ readonly status: string;
15
+ readonly sourceHash: string;
16
+ readonly description: string;
17
+ readonly sourceValueKind: string;
18
+ readonly sourceValue: string;
19
+ readonly translatedValueKind: string;
20
+ readonly translatedValue: string;
21
+ }
22
+ export interface ExchangeSheet {
23
+ readonly name: string;
24
+ readonly columns: readonly string[];
25
+ readonly rows: readonly TranslationWorkbookRow[];
26
+ }
27
+ export interface ExchangeWorkbook {
28
+ readonly version: 1;
29
+ readonly sheets: readonly ExchangeSheet[];
30
+ }
31
+ export interface SerializedAuthoringTranslation {
32
+ readonly value: EncodedExchangeValue;
33
+ readonly sourceHash: string;
34
+ readonly status: AuthoringTranslationStatus;
35
+ }
36
+ export interface SerializedAuthoringCatalogEntry {
37
+ readonly key: I18nCatalogKey;
38
+ readonly kind: I18nEntryKind;
39
+ readonly sourceLocale: string;
40
+ readonly sourceValue: EncodedExchangeValue;
41
+ readonly translations: Readonly<Record<string, SerializedAuthoringTranslation>>;
42
+ readonly description?: string;
43
+ }
44
+ export interface SerializedAuthoringCatalog {
45
+ readonly namespace: string;
46
+ readonly entries: readonly SerializedAuthoringCatalogEntry[];
47
+ }
48
+ export interface CatalogBundle {
49
+ readonly version: 1;
50
+ readonly catalogs: readonly SerializedAuthoringCatalog[];
51
+ }
52
+ export declare function encodeExchangeValue(value: unknown): EncodedExchangeValue;
53
+ export declare function decodeExchangeValue(encoded: EncodedExchangeValue): unknown;
54
+ export declare function exportTranslationWorkbook(catalogs: readonly AuthoringCatalog[], locale: string): ExchangeWorkbook;
55
+ export declare function importTranslationWorkbook(workbook: ExchangeWorkbook): readonly TranslationRow[];
56
+ export declare function exportCatalogBundle(catalogs: readonly AuthoringCatalog[]): CatalogBundle;
57
+ export declare function importCatalogBundle(bundle: CatalogBundle): readonly AuthoringCatalog[];
58
+ //# sourceMappingURL=exchange.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exchange.d.ts","sourceRoot":"","sources":["../src/exchange.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EAEd,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,gBAAgB,EAGhB,0BAA0B,EAC1B,cAAc,EACf,MAAM,YAAY,CAAC;AAGpB,MAAM,MAAM,iBAAiB,GACzB,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,MAAM,GACN,QAAQ,GACR,OAAO,GACP,WAAW,CAAC;AAEhB,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACt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M,CAAC;CAC/B;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,SAAS,+BAA+B,EAAE,CAAC;CAC9D;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,SAAS,0BAA0B,EAAE,CAAC;CAC1D;AA+CD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,oBAAoB,CA0BxE;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAgD1E;AA2DD,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,SAAS,gBAAgB,EAAE,EACrC,MAAM,EAAE,MAAM,GACb,gBAAgB,CAWlB;AAED,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,SAAS,cAAc,EAAE,CAkB/F;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,SAAS,gBAAgB,EAAE,GAAG,aAAa,CAwBxF;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,SAAS,gBAAgB,EAAE,CAsCtF"}
@@ -0,0 +1,258 @@
1
+ import { exportTranslationRows } from './tools.js';
2
+ const TRANSLATION_WORKBOOK_COLUMNS = [
3
+ 'namespace',
4
+ 'id',
5
+ 'kind',
6
+ 'sourceLocale',
7
+ 'targetLocale',
8
+ 'status',
9
+ 'sourceHash',
10
+ 'description',
11
+ 'sourceValueKind',
12
+ 'sourceValue',
13
+ 'translatedValueKind',
14
+ 'translatedValue',
15
+ ];
16
+ function isReference(value) {
17
+ return typeof value === 'object'
18
+ && value !== null
19
+ && '$ref' in value
20
+ && typeof value.$ref === 'object'
21
+ && value.$ref !== null;
22
+ }
23
+ function isEntryKind(value) {
24
+ return value === 'message' || value === 'resource' || value === 'data';
25
+ }
26
+ function isTranslationStatus(value) {
27
+ return value === 'current' || value === 'stale' || value === 'missing';
28
+ }
29
+ function assertObject(value, message) {
30
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
31
+ throw new Error(message);
32
+ }
33
+ }
34
+ function parseJson(payload, message) {
35
+ try {
36
+ return JSON.parse(payload);
37
+ }
38
+ catch {
39
+ throw new Error(message);
40
+ }
41
+ }
42
+ export function encodeExchangeValue(value) {
43
+ if (isReference(value)) {
44
+ return {
45
+ kind: 'reference',
46
+ payload: JSON.stringify(value.$ref),
47
+ };
48
+ }
49
+ if (typeof value === 'string') {
50
+ return { kind: 'string', payload: value };
51
+ }
52
+ if (typeof value === 'number') {
53
+ return { kind: 'number', payload: String(value) };
54
+ }
55
+ if (typeof value === 'boolean') {
56
+ return { kind: 'boolean', payload: value ? 'true' : 'false' };
57
+ }
58
+ if (value === null) {
59
+ return { kind: 'null', payload: '' };
60
+ }
61
+ if (Array.isArray(value)) {
62
+ return { kind: 'array', payload: JSON.stringify(value) };
63
+ }
64
+ if (typeof value === 'object') {
65
+ return { kind: 'object', payload: JSON.stringify(value) };
66
+ }
67
+ throw new Error(`Invalid exchange value: unsupported type ${typeof value}`);
68
+ }
69
+ export function decodeExchangeValue(encoded) {
70
+ switch (encoded.kind) {
71
+ case 'string':
72
+ return encoded.payload;
73
+ case 'number': {
74
+ const value = Number(encoded.payload);
75
+ if (Number.isNaN(value)) {
76
+ throw new Error(`Invalid exchange value: expected number payload, received ${encoded.payload}`);
77
+ }
78
+ return value;
79
+ }
80
+ case 'boolean':
81
+ if (encoded.payload === 'true') {
82
+ return true;
83
+ }
84
+ if (encoded.payload === 'false') {
85
+ return false;
86
+ }
87
+ throw new Error(`Invalid exchange value: expected boolean payload, received ${encoded.payload}`);
88
+ case 'null':
89
+ return null;
90
+ case 'array': {
91
+ const value = parseJson(encoded.payload, 'Invalid exchange value: expected array payload');
92
+ if (!Array.isArray(value)) {
93
+ throw new Error('Invalid exchange value: expected array payload');
94
+ }
95
+ return value;
96
+ }
97
+ case 'object': {
98
+ const value = parseJson(encoded.payload, 'Invalid exchange value: expected object payload');
99
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
100
+ throw new Error('Invalid exchange value: expected object payload');
101
+ }
102
+ return value;
103
+ }
104
+ case 'reference': {
105
+ const value = parseJson(encoded.payload, 'Invalid exchange value: expected reference payload');
106
+ assertObject(value, 'Invalid exchange value: expected reference payload');
107
+ const namespace = value['namespace'];
108
+ const id = value['id'];
109
+ if (typeof namespace !== 'string' || typeof id !== 'string') {
110
+ throw new Error('Invalid exchange value: expected reference payload');
111
+ }
112
+ return { $ref: { namespace, id } };
113
+ }
114
+ default:
115
+ throw new Error('Invalid exchange value: unknown kind');
116
+ }
117
+ }
118
+ function rowToTranslationRow(row) {
119
+ if (!isEntryKind(row.kind)) {
120
+ throw new Error(`Invalid translation workbook: unknown entry kind ${row.kind}`);
121
+ }
122
+ if (!isTranslationStatus(row.status)) {
123
+ throw new Error(`Invalid translation workbook: unknown translation status ${row.status}`);
124
+ }
125
+ const sourceValue = decodeExchangeValue({
126
+ kind: row.sourceValueKind,
127
+ payload: row.sourceValue,
128
+ });
129
+ let translatedValue;
130
+ if (row.translatedValueKind !== '' || row.translatedValue !== '') {
131
+ translatedValue = decodeExchangeValue({
132
+ kind: row.translatedValueKind,
133
+ payload: row.translatedValue,
134
+ });
135
+ }
136
+ return {
137
+ namespace: row.namespace,
138
+ id: row.id,
139
+ kind: row.kind,
140
+ sourceLocale: row.sourceLocale,
141
+ targetLocale: row.targetLocale,
142
+ sourceValue,
143
+ translatedValue,
144
+ status: row.status,
145
+ sourceHash: row.sourceHash,
146
+ description: row.description === '' ? undefined : row.description,
147
+ };
148
+ }
149
+ function translationRowToWorkbookRow(row) {
150
+ const encodedSource = encodeExchangeValue(row.sourceValue);
151
+ const encodedTranslated = row.translatedValue === undefined
152
+ ? undefined
153
+ : encodeExchangeValue(row.translatedValue);
154
+ return {
155
+ namespace: row.namespace,
156
+ id: row.id,
157
+ kind: row.kind,
158
+ sourceLocale: row.sourceLocale,
159
+ targetLocale: row.targetLocale,
160
+ status: row.status,
161
+ sourceHash: row.sourceHash,
162
+ description: row.description ?? '',
163
+ sourceValueKind: encodedSource.kind,
164
+ sourceValue: encodedSource.payload,
165
+ translatedValueKind: encodedTranslated?.kind ?? '',
166
+ translatedValue: encodedTranslated?.payload ?? '',
167
+ };
168
+ }
169
+ export function exportTranslationWorkbook(catalogs, locale) {
170
+ return {
171
+ version: 1,
172
+ sheets: [
173
+ {
174
+ name: `translations-${locale}`,
175
+ columns: TRANSLATION_WORKBOOK_COLUMNS,
176
+ rows: exportTranslationRows(catalogs, locale).map((row) => translationRowToWorkbookRow(row)),
177
+ },
178
+ ],
179
+ };
180
+ }
181
+ export function importTranslationWorkbook(workbook) {
182
+ if (workbook.version !== 1 || !Array.isArray(workbook.sheets)) {
183
+ throw new Error('Invalid translation workbook: expected versioned workbook payload');
184
+ }
185
+ const rows = [];
186
+ for (const sheet of workbook.sheets) {
187
+ if (!TRANSLATION_WORKBOOK_COLUMNS.every((column) => sheet.columns.includes(column))) {
188
+ throw new Error(`Invalid translation workbook: missing required columns in ${sheet.name}`);
189
+ }
190
+ for (const row of sheet.rows) {
191
+ if (!TRANSLATION_WORKBOOK_COLUMNS.every((column) => typeof row[column] === 'string')) {
192
+ throw new Error(`Invalid translation workbook: row in ${sheet.name} contains non-string cells`);
193
+ }
194
+ rows.push(rowToTranslationRow(row));
195
+ }
196
+ }
197
+ return rows;
198
+ }
199
+ export function exportCatalogBundle(catalogs) {
200
+ return {
201
+ version: 1,
202
+ catalogs: catalogs.map((catalog) => ({
203
+ namespace: catalog.namespace,
204
+ entries: catalog.entries.map((entry) => ({
205
+ key: entry.key,
206
+ kind: entry.kind,
207
+ sourceLocale: entry.sourceLocale,
208
+ sourceValue: encodeExchangeValue(entry.sourceValue),
209
+ translations: Object.fromEntries(Object.entries(entry.translations).map(([locale, translation]) => [
210
+ locale,
211
+ {
212
+ value: encodeExchangeValue(translation.value),
213
+ sourceHash: translation.sourceHash,
214
+ status: translation.status,
215
+ },
216
+ ])),
217
+ ...(entry.description === undefined ? {} : { description: entry.description }),
218
+ })),
219
+ })),
220
+ };
221
+ }
222
+ export function importCatalogBundle(bundle) {
223
+ if (bundle.version !== 1 || !Array.isArray(bundle.catalogs)) {
224
+ throw new Error('Invalid catalog bundle: expected versioned bundle payload');
225
+ }
226
+ return bundle.catalogs.map((catalog) => ({
227
+ namespace: catalog.namespace,
228
+ entries: catalog.entries.map((entry) => {
229
+ if (!isEntryKind(entry.kind)) {
230
+ throw new Error(`Invalid catalog bundle: unknown entry kind ${entry.kind}`);
231
+ }
232
+ const serializedTranslations = entry.translations;
233
+ const translationEntries = Object.entries(serializedTranslations);
234
+ const translations = Object.fromEntries(translationEntries.map(([locale, translation]) => {
235
+ if (!isTranslationStatus(translation.status)) {
236
+ throw new Error(`Invalid catalog bundle: unknown translation status ${translation.status}`);
237
+ }
238
+ return [
239
+ locale,
240
+ {
241
+ value: decodeExchangeValue(translation.value),
242
+ sourceHash: translation.sourceHash,
243
+ status: translation.status,
244
+ },
245
+ ];
246
+ }));
247
+ return {
248
+ key: entry.key,
249
+ kind: entry.kind,
250
+ sourceLocale: entry.sourceLocale,
251
+ sourceValue: decodeExchangeValue(entry.sourceValue),
252
+ translations,
253
+ ...(entry.description === undefined ? {} : { description: entry.description }),
254
+ };
255
+ }),
256
+ }));
257
+ }
258
+ //# sourceMappingURL=exchange.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exchange.js","sourceRoot":"","sources":["../src/exchange.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAmEnD,MAAM,4BAA4B,GAAG;IACnC,WAAW;IACX,IAAI;IACJ,MAAM;IACN,cAAc;IACd,cAAc;IACd,QAAQ;IACR,YAAY;IACZ,aAAa;IACb,iBAAiB;IACjB,aAAa;IACb,qBAAqB;IACrB,iBAAiB;CACT,CAAC;AAEX,SAAS,WAAW,CA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 @@
1
+ export { parseCatalogBundleJson, parseExchangeSheet, serializeCatalogBundleJson, serializeExchangeSheet, type DelimitedFormat, } from './adapters.js';
2
+ export { decodeExchangeValue, encodeExchangeValue, exportCatalogBundle, exportTranslationWorkbook, importCatalogBundle, importTranslationWorkbook, type CatalogBundle, type EncodedExchangeValue, type ExchangeSheet, type ExchangeValueKind, type ExchangeWorkbook, type SerializedAuthoringCatalog, type SerializedAuthoringCatalogEntry, type SerializedAuthoringTranslation, type TranslationWorkbookRow, } from './exchange.js';
3
+ export { compileCatalogs, exportTranslationRows, hashSourceValue, importTranslationRows, markStaleTranslations, pseudoLocalize, ref, type AuthoringCatalog, type AuthoringCatalogEntry, type AuthoringTranslation, type AuthoringTranslationStatus, type TranslationRow, } from './tools.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,0BAA0B,EAC1B,sBAAsB,EACtB,KAAK,eAAe,GACrB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,EACnB,yBAAyB,EACzB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,0BAA0B,EAC/B,KAAK,+BAA+B,EACpC,KAAK,8BAA8B,EACnC,KAAK,sBAAsB,GAC5B,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACd,GAAG,EACH,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,cAAc,GACpB,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { parseCatalogBundleJson, parseExchangeSheet, serializeCatalogBundleJson, serializeExchangeSheet, } from './adapters.js';
2
+ export { decodeExchangeValue, encodeExchangeValue, exportCatalogBundle, exportTranslationWorkbook, importCatalogBundle, importTranslationWorkbook, } from './exchange.js';
3
+ export { compileCatalogs, exportTranslationRows, hashSourceValue, importTranslationRows, markStaleTranslations, pseudoLocalize, ref, } from './tools.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,0BAA0B,EAC1B,sBAAsB,GAEvB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,EACnB,yBAAyB,GAU1B,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACd,GAAG,GAMJ,MAAM,YAAY,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { type I18nCatalog, type I18nCatalogKey, type I18nEntryKind, type I18nReference } from '@flyingrobots/bijou-i18n';
2
+ export { ref } from '@flyingrobots/bijou-i18n';
3
+ export type AuthoringTranslationStatus = 'current' | 'stale' | 'missing';
4
+ export interface AuthoringTranslation<T = unknown> {
5
+ readonly value: T | I18nReference;
6
+ readonly sourceHash: string;
7
+ readonly status: AuthoringTranslationStatus;
8
+ }
9
+ export interface AuthoringCatalogEntry<T = unknown> {
10
+ readonly key: I18nCatalogKey;
11
+ readonly kind: I18nEntryKind;
12
+ readonly sourceLocale: string;
13
+ readonly sourceValue: T | I18nReference;
14
+ readonly translations: Readonly<Record<string, AuthoringTranslation<T>>>;
15
+ readonly description?: string;
16
+ }
17
+ export interface AuthoringCatalog {
18
+ readonly namespace: string;
19
+ readonly entries: readonly AuthoringCatalogEntry[];
20
+ }
21
+ export interface TranslationRow {
22
+ readonly namespace: string;
23
+ readonly id: string;
24
+ readonly kind: I18nEntryKind;
25
+ readonly sourceLocale: string;
26
+ readonly targetLocale: string;
27
+ readonly sourceValue: unknown;
28
+ readonly translatedValue?: unknown;
29
+ readonly status: AuthoringTranslationStatus;
30
+ readonly sourceHash: string;
31
+ readonly description?: string;
32
+ }
33
+ export declare function hashSourceValue(value: unknown): string;
34
+ export declare function markStaleTranslations(catalogs: readonly AuthoringCatalog[]): readonly AuthoringCatalog[];
35
+ export declare function exportTranslationRows(catalogs: readonly AuthoringCatalog[], locale: string): readonly TranslationRow[];
36
+ export declare function importTranslationRows(catalogs: readonly AuthoringCatalog[], rows: readonly TranslationRow[]): readonly AuthoringCatalog[];
37
+ export declare function compileCatalogs(catalogs: readonly AuthoringCatalog[]): readonly I18nCatalog[];
38
+ export declare function pseudoLocalize(value: string): string;
39
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAE/C,MAAM,MAAM,0BAA0B,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AAEzE,MAAM,WAAW,oBAAoB,CAAC,CAAC,GAAG,OAAO;IAC/C,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,aAAa,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,0BAA0B,CAAC;CAC7C;AAED,MAAM,WAAW,qBAAqB,CAAC,CAAC,GAAG,OAAO;IAChD,QAAQ,CAAC,GAAG,EA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AED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,SAAS,gBAAgB,EAAE,EACrC,IAAI,EAAE,SAAS,cAAc,EAAE,GAC9B,SAAS,gBAAgB,EAAE,CA8B7B;AAwBD,wBAAgB,eAAe,CAAC,QAAQ,EAAE,SAAS,gBAAgB,EAAE,GAAG,SAAS,WAAW,EAAE,CA+B7F;AAyDD,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAqBpD"}
package/dist/tools.js ADDED
@@ -0,0 +1,244 @@
1
+ export { ref } from '@flyingrobots/bijou-i18n';
2
+ function stableStringify(value) {
3
+ if (Array.isArray(value)) {
4
+ return `[${value.map((item) => stableStringify(item)).join(',')}]`;
5
+ }
6
+ if (typeof value === 'object' && value !== null) {
7
+ const entries = Object.entries(value)
8
+ .sort(([left], [right]) => left.localeCompare(right))
9
+ .map(([key, entryValue]) => `${JSON.stringify(key)}:${stableStringify(entryValue)}`);
10
+ return `{${entries.join(',')}}`;
11
+ }
12
+ return JSON.stringify(value);
13
+ }
14
+ function keyToString(key) {
15
+ return `${key.namespace}:${key.id}`;
16
+ }
17
+ function isReference(value) {
18
+ return typeof value === 'object'
19
+ && value !== null
20
+ && '$ref' in value
21
+ && typeof value.$ref === 'object'
22
+ && value.$ref !== null;
23
+ }
24
+ export function hashSourceValue(value) {
25
+ const source = stableStringify(value);
26
+ let hash = 2166136261;
27
+ for (let index = 0; index < source.length; index += 1) {
28
+ hash ^= source.charCodeAt(index);
29
+ hash = Math.imul(hash, 16777619);
30
+ }
31
+ return (hash >>> 0).toString(16).padStart(8, '0');
32
+ }
33
+ export function markStaleTranslations(catalogs) {
34
+ return catalogs.map((catalog) => ({
35
+ ...catalog,
36
+ entries: catalog.entries.map((entry) => {
37
+ const currentSourceHash = hashSourceValue(entry.sourceValue);
38
+ const translations = Object.fromEntries(Object.entries(entry.translations).map(([locale, translation]) => [
39
+ locale,
40
+ {
41
+ ...translation,
42
+ status: translation.sourceHash === currentSourceHash ? 'current' : 'stale',
43
+ },
44
+ ]));
45
+ return {
46
+ ...entry,
47
+ translations,
48
+ };
49
+ }),
50
+ }));
51
+ }
52
+ export function exportTranslationRows(catalogs, locale) {
53
+ const rows = [];
54
+ for (const catalog of catalogs) {
55
+ for (const entry of catalog.entries) {
56
+ const sourceHash = hashSourceValue(entry.sourceValue);
57
+ const translation = entry.translations[locale];
58
+ if (translation === undefined) {
59
+ rows.push({
60
+ namespace: entry.key.namespace,
61
+ id: entry.key.id,
62
+ kind: entry.kind,
63
+ sourceLocale: entry.sourceLocale,
64
+ targetLocale: locale,
65
+ sourceValue: entry.sourceValue,
66
+ status: 'missing',
67
+ sourceHash,
68
+ description: entry.description,
69
+ });
70
+ continue;
71
+ }
72
+ if (translation.status === 'current') {
73
+ continue;
74
+ }
75
+ rows.push({
76
+ namespace: entry.key.namespace,
77
+ id: entry.key.id,
78
+ kind: entry.kind,
79
+ sourceLocale: entry.sourceLocale,
80
+ targetLocale: locale,
81
+ sourceValue: entry.sourceValue,
82
+ translatedValue: translation.value,
83
+ status: translation.status,
84
+ sourceHash,
85
+ description: entry.description,
86
+ });
87
+ }
88
+ }
89
+ return rows;
90
+ }
91
+ export function importTranslationRows(catalogs, rows) {
92
+ const rowsByKey = new Map();
93
+ for (const row of rows) {
94
+ rowsByKey.set(`${row.namespace}:${row.id}:${row.targetLocale}`, row);
95
+ }
96
+ return catalogs.map((catalog) => ({
97
+ ...catalog,
98
+ entries: catalog.entries.map((entry) => {
99
+ const translations = { ...entry.translations };
100
+ for (const [rowKey, row] of rowsByKey.entries()) {
101
+ const expectedPrefix = `${entry.key.namespace}:${entry.key.id}:`;
102
+ if (!rowKey.startsWith(expectedPrefix)) {
103
+ continue;
104
+ }
105
+ if (row.translatedValue === undefined) {
106
+ continue;
107
+ }
108
+ translations[row.targetLocale] = {
109
+ value: row.translatedValue,
110
+ sourceHash: row.sourceHash,
111
+ status: 'current',
112
+ };
113
+ }
114
+ return {
115
+ ...entry,
116
+ translations,
117
+ };
118
+ }),
119
+ }));
120
+ }
121
+ function validateAndResolve(entryMap, value, seen) {
122
+ if (!isReference(value)) {
123
+ return value;
124
+ }
125
+ const refKey = keyToString(value.$ref);
126
+ if (seen.has(refKey)) {
127
+ throw new Error(`Cyclic i18n tooling reference: ${refKey}`);
128
+ }
129
+ const referencedEntry = entryMap.get(refKey);
130
+ if (referencedEntry === undefined) {
131
+ throw new Error(`Missing i18n tooling reference: ${refKey}`);
132
+ }
133
+ seen.add(refKey);
134
+ const resolved = validateAndResolve(entryMap, referencedEntry.sourceValue, seen);
135
+ seen.delete(refKey);
136
+ return resolved;
137
+ }
138
+ export function compileCatalogs(catalogs) {
139
+ const entryMap = new Map();
140
+ for (const catalog of catalogs) {
141
+ for (const entry of catalog.entries) {
142
+ entryMap.set(keyToString(entry.key), entry);
143
+ }
144
+ }
145
+ return catalogs.map((catalog) => ({
146
+ namespace: catalog.namespace,
147
+ entries: catalog.entries.map((entry) => {
148
+ validateAndResolve(entryMap, entry.sourceValue, new Set([keyToString(entry.key)]));
149
+ for (const translation of Object.values(entry.translations)) {
150
+ validateAndResolve(entryMap, translation.value, new Set([keyToString(entry.key)]));
151
+ }
152
+ const values = {
153
+ [entry.sourceLocale]: entry.sourceValue,
154
+ };
155
+ for (const [locale, translation] of Object.entries(entry.translations)) {
156
+ values[locale] = translation.value;
157
+ }
158
+ const compiledEntry = {
159
+ key: entry.key,
160
+ kind: entry.kind,
161
+ sourceLocale: entry.sourceLocale,
162
+ values,
163
+ };
164
+ return compiledEntry;
165
+ }),
166
+ }));
167
+ }
168
+ const PSEUDO_MAP = {
169
+ a: 'à',
170
+ b: 'ƀ',
171
+ c: 'ç',
172
+ d: 'đ',
173
+ e: 'ë',
174
+ f: 'ƒ',
175
+ g: 'ğ',
176
+ h: 'ħ',
177
+ i: 'ï',
178
+ j: 'ĵ',
179
+ k: 'ķ',
180
+ l: 'ľ',
181
+ m: 'ɱ',
182
+ n: 'ñ',
183
+ o: 'ø',
184
+ p: 'þ',
185
+ q: 'ʠ',
186
+ r: 'ř',
187
+ s: 'š',
188
+ t: 'ŧ',
189
+ u: 'ü',
190
+ v: 'ṽ',
191
+ w: 'ŵ',
192
+ x: 'ẋ',
193
+ y: 'ÿ',
194
+ z: 'ž',
195
+ A: 'Å',
196
+ B: 'ß',
197
+ C: 'Ç',
198
+ D: 'Ð',
199
+ E: 'Ë',
200
+ F: 'Ƒ',
201
+ G: 'Ĝ',
202
+ H: 'Ħ',
203
+ I: 'Ï',
204
+ J: 'Ĵ',
205
+ K: 'Ҡ',
206
+ L: 'Ŀ',
207
+ M: 'Ṁ',
208
+ N: 'Ń',
209
+ O: 'Ø',
210
+ P: 'Þ',
211
+ Q: 'Ǫ',
212
+ R: 'Ř',
213
+ S: 'Š',
214
+ T: 'Ŧ',
215
+ U: 'Ü',
216
+ V: 'Ṽ',
217
+ W: 'Ŵ',
218
+ X: 'Ẍ',
219
+ Y: 'Ÿ',
220
+ Z: 'Ž',
221
+ };
222
+ export function pseudoLocalize(value) {
223
+ let inPlaceholder = false;
224
+ let result = '';
225
+ for (const char of value) {
226
+ if (char === '{') {
227
+ inPlaceholder = true;
228
+ result += char;
229
+ continue;
230
+ }
231
+ if (char === '}') {
232
+ inPlaceholder = false;
233
+ result += char;
234
+ continue;
235
+ }
236
+ if (inPlaceholder) {
237
+ result += char;
238
+ continue;
239
+ }
240
+ result += PSEUDO_MAP[char] ?? char;
241
+ }
242
+ return `[¡¡ ${result} ~~~ !!]`;
243
+ }
244
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAqC/C,SAAS,eAAe,CAAC,KAAc;IACrC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,E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CAAC,IAAI,IAAI,CAAC;IACrC,CAAC;IACD,OAAO,OAAO,MAAM,UAAU,CAAC;AACjC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@flyingrobots/bijou-i18n-tools",
3
+ "version": "4.1.0",
4
+ "description": "Localization workflow tooling for Bijou — authoring catalogs, stale detection, tabular export/import, and runtime compilation.",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/index.js"
13
+ },
14
+ "./package.json": "./package.json"
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "README.md",
19
+ "LICENSE"
20
+ ],
21
+ "scripts": {
22
+ "build": "tsc -b",
23
+ "prepack": "tsc -b",
24
+ "lint": "tsc --noEmit"
25
+ },
26
+ "dependencies": {
27
+ "@flyingrobots/bijou-i18n": "4.1.0"
28
+ },
29
+ "devDependencies": {
30
+ "@types/node": "^22.0.0",
31
+ "typescript": "^5.9.3",
32
+ "vitest": "^4.0.18"
33
+ },
34
+ "keywords": [
35
+ "i18n",
36
+ "localization",
37
+ "translation",
38
+ "catalogs",
39
+ "bijou",
40
+ "tooling"
41
+ ],
42
+ "author": "James Ross <james@flyingrobots.dev>",
43
+ "license": "Apache-2.0",
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "git+https://github.com/flyingrobots/bijou.git",
47
+ "directory": "packages/bijou-i18n-tools"
48
+ },
49
+ "homepage": "https://github.com/flyingrobots/bijou",
50
+ "bugs": "https://github.com/flyingrobots/bijou/issues",
51
+ "engines": {
52
+ "node": ">=18"
53
+ },
54
+ "publishConfig": {
55
+ "access": "public",
56
+ "provenance": true
57
+ }
58
+ }