react-cheminfo 0.23.0 → 0.25.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/README.md +39 -26
- package/lib/chrome/ui/HeaderToggle.d.ts +52 -0
- package/lib/chrome/ui/HeaderToggle.d.ts.map +1 -0
- package/lib/chrome/ui/HeaderToggle.js +31 -0
- package/lib/chrome/ui/HeaderToggle.js.map +1 -0
- package/lib/chrome/ui/index.d.ts +2 -0
- package/lib/chrome/ui/index.d.ts.map +1 -1
- package/lib/chrome/ui/index.js +1 -0
- package/lib/chrome/ui/index.js.map +1 -1
- package/lib/citation/core/gfn2Paper.d.ts +10 -0
- package/lib/citation/core/gfn2Paper.d.ts.map +1 -0
- package/lib/citation/core/gfn2Paper.js +28 -0
- package/lib/citation/core/gfn2Paper.js.map +1 -0
- package/lib/citation/core/index.d.ts +1 -0
- package/lib/citation/core/index.d.ts.map +1 -1
- package/lib/citation/core/index.js +1 -0
- package/lib/citation/core/index.js.map +1 -1
- package/lib/clipboard/ui/ClickToCopy.d.ts +8 -7
- package/lib/clipboard/ui/ClickToCopy.d.ts.map +1 -1
- package/lib/clipboard/ui/ClickToCopy.js +3 -3
- package/lib/clipboard/ui/ClickToCopy.js.map +1 -1
- package/lib/conformers.d.ts +27 -0
- package/lib/conformers.d.ts.map +1 -0
- package/lib/conformers.js +19 -0
- package/lib/conformers.js.map +1 -0
- package/lib/core.d.ts +1 -0
- package/lib/core.d.ts.map +1 -1
- package/lib/core.js +1 -0
- package/lib/core.js.map +1 -1
- package/lib/credits/core/credits.d.ts +12 -0
- package/lib/credits/core/credits.d.ts.map +1 -1
- package/lib/credits/core/credits.js +14 -0
- package/lib/credits/core/credits.js.map +1 -1
- package/lib/ecosystem/core/index.d.ts +1 -1
- package/lib/ecosystem/core/index.d.ts.map +1 -1
- package/lib/ecosystem/core/index.js.map +1 -1
- package/lib/ecosystem/core/sites.d.ts +11 -1
- package/lib/ecosystem/core/sites.d.ts.map +1 -1
- package/lib/ecosystem/core/sites.js +11 -4
- package/lib/ecosystem/core/sites.js.map +1 -1
- package/lib/ecosystem/ui/EcosystemLinks.d.ts.map +1 -1
- package/lib/ecosystem/ui/EcosystemLinks.js +3 -1
- package/lib/ecosystem/ui/EcosystemLinks.js.map +1 -1
- package/lib/ecosystem/ui/SiteTile.d.ts.map +1 -1
- package/lib/ecosystem/ui/SiteTile.js +3 -1
- package/lib/ecosystem/ui/SiteTile.js.map +1 -1
- package/lib/ecosystem/ui/glyphs.d.ts.map +1 -1
- package/lib/ecosystem/ui/glyphs.js +6 -5
- package/lib/ecosystem/ui/glyphs.js.map +1 -1
- package/lib/format/core/index.d.ts +1 -1
- package/lib/format/core/index.d.ts.map +1 -1
- package/lib/format/core/index.js +1 -1
- package/lib/format/core/index.js.map +1 -1
- package/lib/format/core/words.d.ts +9 -0
- package/lib/format/core/words.d.ts.map +1 -1
- package/lib/format/core/words.js +16 -0
- package/lib/format/core/words.js.map +1 -1
- package/lib/language/core/index.d.ts +3 -0
- package/lib/language/core/index.d.ts.map +1 -0
- package/lib/language/core/index.js +3 -0
- package/lib/language/core/index.js.map +1 -0
- package/lib/language/core/languageName.d.ts +8 -0
- package/lib/language/core/languageName.d.ts.map +1 -0
- package/lib/language/core/languageName.js +16 -0
- package/lib/language/core/languageName.js.map +1 -0
- package/lib/language/core/languageParam.d.ts +35 -0
- package/lib/language/core/languageParam.d.ts.map +1 -0
- package/lib/language/core/languageParam.js +67 -0
- package/lib/language/core/languageParam.js.map +1 -0
- package/lib/language/ui/SiteLanguage.d.ts +20 -0
- package/lib/language/ui/SiteLanguage.d.ts.map +1 -0
- package/lib/language/ui/SiteLanguage.js +14 -0
- package/lib/language/ui/SiteLanguage.js.map +1 -0
- package/lib/language/ui/index.d.ts +4 -0
- package/lib/language/ui/index.d.ts.map +1 -0
- package/lib/language/ui/index.js +3 -0
- package/lib/language/ui/index.js.map +1 -0
- package/lib/language/ui/siteLanguageContext.d.ts +12 -0
- package/lib/language/ui/siteLanguageContext.d.ts.map +1 -0
- package/lib/language/ui/siteLanguageContext.js +19 -0
- package/lib/language/ui/siteLanguageContext.js.map +1 -0
- package/lib/orbital/core/atomicOrbitals.d.ts +9 -1
- package/lib/orbital/core/atomicOrbitals.d.ts.map +1 -1
- package/lib/orbital/core/atomicOrbitals.js +7 -0
- package/lib/orbital/core/atomicOrbitals.js.map +1 -1
- package/lib/orbital/core/hydrogenic.d.ts +2 -1
- package/lib/orbital/core/hydrogenic.d.ts.map +1 -1
- package/lib/orbital/core/hydrogenic.js +2 -1
- package/lib/orbital/core/hydrogenic.js.map +1 -1
- package/lib/orbital/core/index.d.ts +1 -0
- package/lib/orbital/core/index.d.ts.map +1 -1
- package/lib/orbital/core/index.js +1 -0
- package/lib/orbital/core/index.js.map +1 -1
- package/lib/orbital/core/slaterEnergy.d.ts +35 -0
- package/lib/orbital/core/slaterEnergy.d.ts.map +1 -0
- package/lib/orbital/core/slaterEnergy.js +66 -0
- package/lib/orbital/core/slaterEnergy.js.map +1 -0
- package/lib/shared/ui/MenuButton.d.ts +3 -2
- package/lib/shared/ui/MenuButton.d.ts.map +1 -1
- package/lib/shared/ui/MenuButton.js +1 -1
- package/lib/shared/ui/MenuButton.js.map +1 -1
- package/lib/structure/core/conformerMinimise.d.ts +36 -0
- package/lib/structure/core/conformerMinimise.d.ts.map +1 -0
- package/lib/structure/core/conformerMinimise.js +81 -0
- package/lib/structure/core/conformerMinimise.js.map +1 -0
- package/lib/structure/core/conformerMinimum.d.ts +62 -0
- package/lib/structure/core/conformerMinimum.d.ts.map +1 -0
- package/lib/structure/core/conformerMinimum.js +90 -0
- package/lib/structure/core/conformerMinimum.js.map +1 -0
- package/lib/structure/core/conformerOptions.d.ts +62 -0
- package/lib/structure/core/conformerOptions.d.ts.map +1 -0
- package/lib/structure/core/conformerOptions.js +83 -0
- package/lib/structure/core/conformerOptions.js.map +1 -0
- package/lib/structure/core/conformerRefine.d.ts +104 -0
- package/lib/structure/core/conformerRefine.d.ts.map +1 -0
- package/lib/structure/core/conformerRefine.js +130 -0
- package/lib/structure/core/conformerRefine.js.map +1 -0
- package/lib/structure/core/conformerRefineRank.d.ts +36 -0
- package/lib/structure/core/conformerRefineRank.d.ts.map +1 -0
- package/lib/structure/core/conformerRefineRank.js +69 -0
- package/lib/structure/core/conformerRefineRank.js.map +1 -0
- package/lib/structure/core/conformerSession.d.ts +50 -0
- package/lib/structure/core/conformerSession.d.ts.map +1 -0
- package/lib/structure/core/conformerSession.js +88 -0
- package/lib/structure/core/conformerSession.js.map +1 -0
- package/lib/structure/core/conformerShape.d.ts +36 -0
- package/lib/structure/core/conformerShape.d.ts.map +1 -0
- package/lib/structure/core/conformerShape.js +150 -0
- package/lib/structure/core/conformerShape.js.map +1 -0
- package/lib/structure/core/conformers.d.ts +107 -0
- package/lib/structure/core/conformers.d.ts.map +1 -0
- package/lib/structure/core/conformers.js +149 -0
- package/lib/structure/core/conformers.js.map +1 -0
- package/lib/structure/core/geometryRelaxer.d.ts +66 -0
- package/lib/structure/core/geometryRelaxer.d.ts.map +1 -0
- package/lib/structure/core/geometryRelaxer.js +2 -0
- package/lib/structure/core/geometryRelaxer.js.map +1 -0
- package/lib/structure/core/index.d.ts +4 -0
- package/lib/structure/core/index.d.ts.map +1 -1
- package/lib/structure/core/index.js +2 -0
- package/lib/structure/core/index.js.map +1 -1
- package/lib/structure/core/moleculeCoordinates.d.ts +31 -0
- package/lib/structure/core/moleculeCoordinates.d.ts.map +1 -0
- package/lib/structure/core/moleculeCoordinates.js +80 -0
- package/lib/structure/core/moleculeCoordinates.js.map +1 -0
- package/lib/structure/core/molfileExport.d.ts +42 -0
- package/lib/structure/core/molfileExport.d.ts.map +1 -0
- package/lib/structure/core/molfileExport.js +47 -0
- package/lib/structure/core/molfileExport.js.map +1 -0
- package/lib/structure/core/oclResources.d.ts +12 -0
- package/lib/structure/core/oclResources.d.ts.map +1 -0
- package/lib/structure/core/oclResources.js +35 -0
- package/lib/structure/core/oclResources.js.map +1 -0
- package/lib/translate/core/catalog.d.ts +61 -0
- package/lib/translate/core/catalog.d.ts.map +1 -0
- package/lib/translate/core/catalog.js +49 -0
- package/lib/translate/core/catalog.js.map +1 -0
- package/lib/translate/core/checkTranslation.d.ts +32 -0
- package/lib/translate/core/checkTranslation.d.ts.map +1 -0
- package/lib/translate/core/checkTranslation.js +98 -0
- package/lib/translate/core/checkTranslation.js.map +1 -0
- package/lib/translate/core/contribution.d.ts +88 -0
- package/lib/translate/core/contribution.d.ts.map +1 -0
- package/lib/translate/core/contribution.js +14 -0
- package/lib/translate/core/contribution.js.map +1 -0
- package/lib/translate/core/index.d.ts +19 -0
- package/lib/translate/core/index.d.ts.map +1 -0
- package/lib/translate/core/index.js +15 -0
- package/lib/translate/core/index.js.map +1 -0
- package/lib/translate/core/marker.d.ts +45 -0
- package/lib/translate/core/marker.d.ts.map +1 -0
- package/lib/translate/core/marker.js +79 -0
- package/lib/translate/core/marker.js.map +1 -0
- package/lib/translate/core/mergeMessages.d.ts +35 -0
- package/lib/translate/core/mergeMessages.d.ts.map +1 -0
- package/lib/translate/core/mergeMessages.js +69 -0
- package/lib/translate/core/mergeMessages.js.map +1 -0
- package/lib/translate/core/session.d.ts +102 -0
- package/lib/translate/core/session.d.ts.map +1 -0
- package/lib/translate/core/session.js +162 -0
- package/lib/translate/core/session.js.map +1 -0
- package/lib/translate/core/start.d.ts +103 -0
- package/lib/translate/core/start.d.ts.map +1 -0
- package/lib/translate/core/start.js +92 -0
- package/lib/translate/core/start.js.map +1 -0
- package/lib/translate/core/suggestions.d.ts +77 -0
- package/lib/translate/core/suggestions.d.ts.map +1 -0
- package/lib/translate/core/suggestions.js +143 -0
- package/lib/translate/core/suggestions.js.map +1 -0
- package/lib/translate/core/tables.d.ts +100 -0
- package/lib/translate/core/tables.d.ts.map +1 -0
- package/lib/translate/core/tables.js +51 -0
- package/lib/translate/core/tables.js.map +1 -0
- package/lib/translate.d.ts +2 -0
- package/lib/translate.d.ts.map +1 -0
- package/lib/translate.js +6 -0
- package/lib/translate.js.map +1 -0
- package/lib/ui.d.ts +1 -0
- package/lib/ui.d.ts.map +1 -1
- package/lib/ui.js +1 -0
- package/lib/ui.js.map +1 -1
- package/lib/xtb/core/xtbRelaxer.d.ts +61 -0
- package/lib/xtb/core/xtbRelaxer.d.ts.map +1 -0
- package/lib/xtb/core/xtbRelaxer.js +108 -0
- package/lib/xtb/core/xtbRelaxer.js.map +1 -0
- package/lib/xtb.d.ts +11 -0
- package/lib/xtb.d.ts.map +1 -0
- package/lib/xtb.js +10 -0
- package/lib/xtb.js.map +1 -0
- package/package.json +18 -11
- package/src/chrome/ui/HeaderToggle.tsx +100 -0
- package/src/chrome/ui/index.ts +2 -0
- package/src/citation/core/gfn2Paper.ts +32 -0
- package/src/citation/core/index.ts +1 -0
- package/src/clipboard/ui/ClickToCopy.tsx +8 -7
- package/src/conformers.ts +87 -0
- package/src/core.ts +1 -0
- package/src/credits/core/credits.ts +16 -0
- package/src/ecosystem/core/index.ts +1 -0
- package/src/ecosystem/core/sites.ts +24 -4
- package/src/ecosystem/ui/EcosystemLinks.tsx +3 -1
- package/src/ecosystem/ui/SiteTile.tsx +3 -1
- package/src/ecosystem/ui/glyphs.tsx +16 -22
- package/src/format/core/index.ts +1 -1
- package/src/format/core/words.ts +19 -0
- package/src/language/core/index.ts +7 -0
- package/src/language/core/languageName.ts +16 -0
- package/src/language/core/languageParam.ts +70 -0
- package/src/language/ui/SiteLanguage.tsx +26 -0
- package/src/language/ui/index.ts +3 -0
- package/src/language/ui/siteLanguageContext.ts +20 -0
- package/src/orbital/core/atomicOrbitals.ts +17 -1
- package/src/orbital/core/hydrogenic.ts +2 -1
- package/src/orbital/core/index.ts +1 -0
- package/src/orbital/core/slaterEnergy.ts +83 -0
- package/src/shared/ui/MenuButton.tsx +4 -3
- package/src/structure/core/conformerMinimise.ts +99 -0
- package/src/structure/core/conformerMinimum.ts +125 -0
- package/src/structure/core/conformerOptions.ts +125 -0
- package/src/structure/core/conformerRefine.ts +234 -0
- package/src/structure/core/conformerRefineRank.ts +89 -0
- package/src/structure/core/conformerSession.ts +123 -0
- package/src/structure/core/conformerShape.ts +181 -0
- package/src/structure/core/conformers.ts +282 -0
- package/src/structure/core/geometryRelaxer.ts +71 -0
- package/src/structure/core/index.ts +13 -0
- package/src/structure/core/moleculeCoordinates.ts +93 -0
- package/src/structure/core/molfileExport.ts +62 -0
- package/src/structure/core/oclResources.ts +41 -0
- package/src/translate/core/catalog.ts +83 -0
- package/src/translate/core/checkTranslation.ts +128 -0
- package/src/translate/core/contribution.ts +99 -0
- package/src/translate/core/index.ts +72 -0
- package/src/translate/core/marker.ts +85 -0
- package/src/translate/core/mergeMessages.ts +74 -0
- package/src/translate/core/session.ts +250 -0
- package/src/translate/core/start.ts +183 -0
- package/src/translate/core/suggestions.ts +211 -0
- package/src/translate/core/tables.ts +120 -0
- package/src/translate.ts +5 -0
- package/src/ui.ts +1 -0
- package/src/xtb/core/xtbRelaxer.ts +160 -0
- package/src/xtb.ts +16 -0
- package/styles/chrome.css +61 -30
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { TYPE, parse } from '@formatjs/icu-messageformat-parser';
|
|
2
|
+
/**
|
|
3
|
+
* Check a translation against the English message it translates: it must be
|
|
4
|
+
* a valid ICU message and use exactly the placeholders and tags of the source.
|
|
5
|
+
* @param source - The English message.
|
|
6
|
+
* @param translation - The translated message.
|
|
7
|
+
* @returns Every problem found; empty when the translation can be used.
|
|
8
|
+
*/
|
|
9
|
+
export function checkTranslation(source, translation) {
|
|
10
|
+
if (translation.trim() === '') {
|
|
11
|
+
return [{ kind: 'empty', message: 'The translation is empty.' }];
|
|
12
|
+
}
|
|
13
|
+
let expected;
|
|
14
|
+
try {
|
|
15
|
+
expected = messageArguments(source);
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
return [
|
|
19
|
+
{
|
|
20
|
+
kind: 'source-syntax',
|
|
21
|
+
message: `The English message itself is not valid: ${describe(error)}`,
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
|
+
let actual;
|
|
26
|
+
try {
|
|
27
|
+
actual = messageArguments(translation);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
return [{ kind: 'syntax', message: describe(error) }];
|
|
31
|
+
}
|
|
32
|
+
const problems = [];
|
|
33
|
+
for (const argument of expected) {
|
|
34
|
+
if (!actual.has(argument)) {
|
|
35
|
+
problems.push({
|
|
36
|
+
kind: 'missing-argument',
|
|
37
|
+
argument,
|
|
38
|
+
message: `${argument} is in the English message but not in the translation.`,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
for (const argument of actual) {
|
|
43
|
+
if (!expected.has(argument)) {
|
|
44
|
+
problems.push({
|
|
45
|
+
kind: 'unknown-argument',
|
|
46
|
+
argument,
|
|
47
|
+
message: `${argument} is not in the English message, so nothing would fill it.`,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return problems;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The placeholders and tags a message uses, each written as it appears in the
|
|
55
|
+
* message: `{count}` for an argument, `<link>` for a tag.
|
|
56
|
+
* @param message - An ICU message.
|
|
57
|
+
* @returns The set of placeholders and tags.
|
|
58
|
+
* @throws {SyntaxError} When the message does not parse.
|
|
59
|
+
*/
|
|
60
|
+
export function messageArguments(message) {
|
|
61
|
+
const found = new Set();
|
|
62
|
+
collect(parse(message), found);
|
|
63
|
+
return found;
|
|
64
|
+
}
|
|
65
|
+
function collect(elements, found) {
|
|
66
|
+
for (const element of elements) {
|
|
67
|
+
switch (element.type) {
|
|
68
|
+
case TYPE.argument:
|
|
69
|
+
case TYPE.number:
|
|
70
|
+
case TYPE.date:
|
|
71
|
+
case TYPE.time:
|
|
72
|
+
found.add(`{${element.value}}`);
|
|
73
|
+
break;
|
|
74
|
+
case TYPE.select:
|
|
75
|
+
case TYPE.plural:
|
|
76
|
+
found.add(`{${element.value}}`);
|
|
77
|
+
for (const option of Object.values(element.options)) {
|
|
78
|
+
collect(option.value, found);
|
|
79
|
+
}
|
|
80
|
+
break;
|
|
81
|
+
case TYPE.tag:
|
|
82
|
+
found.add(`<${element.value}>`);
|
|
83
|
+
collect(element.children, found);
|
|
84
|
+
break;
|
|
85
|
+
case TYPE.literal:
|
|
86
|
+
case TYPE.pound:
|
|
87
|
+
break;
|
|
88
|
+
// no default
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function describe(error) {
|
|
93
|
+
if (error instanceof Error) {
|
|
94
|
+
return `The message does not parse (${error.message}).`;
|
|
95
|
+
}
|
|
96
|
+
return 'The message does not parse.';
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=checkTranslation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkTranslation.js","sourceRoot":"","sources":["../../../src/translate/core/checkTranslation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,oCAAoC,CAAC;AAwBjE;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAAc,EACd,WAAmB;IAEnB,IAAI,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAC9B,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,2BAA2B,EAAE,CAAC,CAAC;IACnE,CAAC;IAED,IAAI,QAAqB,CAAC;IAC1B,IAAI,CAAC;QACH,QAAQ,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL;gBACE,IAAI,EAAE,eAAe;gBACrB,OAAO,EAAE,4CAA4C,QAAQ,CAAC,KAAK,CAAC,EAAE;aACvE;SACF,CAAC;IACJ,CAAC;IAED,IAAI,MAAmB,CAAC;IACxB,IAAI,CAAC;QACH,MAAM,GAAG,g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AK,IAAI,CAAC,IAAI,CAAC;YACf,KAAK,IAAI,CAAC,IAAI;gBACZ,KAAK,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC;gBAChC,MAAM;YACR,KAAK,IAAI,CAAC,MAAM,CAAC;YACjB,KAAK,IAAI,CAAC,MAAM;gBACd,KAAK,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC;gBAChC,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;oBACpD,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;gBAC/B,CAAC;gBACD,MAAM;YACR,KAAK,IAAI,CAAC,GAAG;gBACX,KAAK,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC;gBAChC,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;gBACjC,MAAM;YACR,KAAK,IAAI,CAAC,OAAO,CAAC;YAClB,KAAK,IAAI,CAAC,KAAK;gBACb,MAAM;YACR,aAAa;QACf,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,+BAA+B,KAAK,CAAC,OAAO,IAAI,CAAC;IAC1D,CAAC;IACD,OAAO,6BAA6B,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the overlay sends the server, and what the server answers.
|
|
3
|
+
*/
|
|
4
|
+
import type { Messages } from './catalog.ts';
|
|
5
|
+
/** The longest message a contribution may carry, in characters. */
|
|
6
|
+
export declare const MAX_MESSAGE_LENGTH = 5000;
|
|
7
|
+
/** The most messages one catalog of a contribution may carry. */
|
|
8
|
+
export declare const MAX_MESSAGES_PER_CATALOG = 2000;
|
|
9
|
+
/** The most catalogs one contribution may carry. */
|
|
10
|
+
export declare const MAX_CATALOGS = 32;
|
|
11
|
+
/** The longest name a translator may be credited under. */
|
|
12
|
+
export declare const MAX_CONTRIBUTOR_LENGTH = 100;
|
|
13
|
+
/** The longest note a translator may leave for the reviewer. */
|
|
14
|
+
export declare const MAX_NOTE_LENGTH = 1000;
|
|
15
|
+
/** The messages translated for one catalog. */
|
|
16
|
+
export interface ContributionCatalog {
|
|
17
|
+
/** The repository the catalog lives in, written `owner/repo`. */
|
|
18
|
+
repository: string;
|
|
19
|
+
/** The catalog directory, relative to the repository root. */
|
|
20
|
+
directory: string;
|
|
21
|
+
/** The translated messages by key. */
|
|
22
|
+
messages: Messages;
|
|
23
|
+
}
|
|
24
|
+
/** One submission from the overlay. */
|
|
25
|
+
export interface Contribution {
|
|
26
|
+
/** The locale the messages are written in. */
|
|
27
|
+
locale: string;
|
|
28
|
+
/** The translated messages, catalog by catalog. */
|
|
29
|
+
catalogs: ContributionCatalog[];
|
|
30
|
+
/**
|
|
31
|
+
* The name the pull request credits.
|
|
32
|
+
* @default undefined
|
|
33
|
+
*/
|
|
34
|
+
contributor?: string;
|
|
35
|
+
/**
|
|
36
|
+
* A note for whoever reviews the pull request.
|
|
37
|
+
* @default undefined
|
|
38
|
+
*/
|
|
39
|
+
note?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Continuation tokens of pull requests this translator opened before: a
|
|
42
|
+
* repository that has an open one gets a new commit there, not a new PR.
|
|
43
|
+
* @default []
|
|
44
|
+
*/
|
|
45
|
+
continuations?: string[];
|
|
46
|
+
}
|
|
47
|
+
/** A pull request a contribution opened or added to. */
|
|
48
|
+
export interface ContributionPullRequest {
|
|
49
|
+
/** The repository the pull request is on, `owner/repo`. */
|
|
50
|
+
repository: string;
|
|
51
|
+
/** Its number. */
|
|
52
|
+
number: number;
|
|
53
|
+
/** Where to read it. */
|
|
54
|
+
url: string;
|
|
55
|
+
/** How many messages this contribution changed in it. */
|
|
56
|
+
messageCount: number;
|
|
57
|
+
/** Whether an existing pull request was added to rather than opened. */
|
|
58
|
+
updated: boolean;
|
|
59
|
+
/** The token that lets the same translator add to it next time. */
|
|
60
|
+
continuation: string;
|
|
61
|
+
}
|
|
62
|
+
/** What a successful submission answers. */
|
|
63
|
+
export interface ContributionResult {
|
|
64
|
+
/** One entry per repository that changed; empty when nothing did. */
|
|
65
|
+
pullRequests: ContributionPullRequest[];
|
|
66
|
+
}
|
|
67
|
+
/** One reason a submission was refused. */
|
|
68
|
+
export interface ContributionProblem {
|
|
69
|
+
/** The repository concerned. */
|
|
70
|
+
repository: string;
|
|
71
|
+
/** The catalog directory concerned. */
|
|
72
|
+
directory: string;
|
|
73
|
+
/**
|
|
74
|
+
* The message concerned, when the problem is about one.
|
|
75
|
+
* @default undefined
|
|
76
|
+
*/
|
|
77
|
+
key?: string;
|
|
78
|
+
/** The sentence the translator reads. */
|
|
79
|
+
message: string;
|
|
80
|
+
}
|
|
81
|
+
/** What a refused submission answers. */
|
|
82
|
+
export interface ContributionRejection {
|
|
83
|
+
/** A summary of why. */
|
|
84
|
+
error: string;
|
|
85
|
+
/** Every problem found. */
|
|
86
|
+
problems: ContributionProblem[];
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contribution.d.ts","sourceRoot":"","sources":["../../../src/translate/core/contribution.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C,mEAAmE;AACnE,eAAO,MAAM,kBAAkB,OAAO,CAAC;AAEvC,iEAAiE;AACjE,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAE7C,oDAAoD;AACpD,eAAO,MAAM,YAAY,KAAK,CAAC;AAE/B,2DAA2D;AAC3D,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C,gEAAgE;AAChE,eAAO,MAAM,eAAe,OAAO,CAAC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QAAQ,EAAE,mBAAmB,EAAE,CAAC;CACjC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the overlay sends the server, and what the server answers.
|
|
3
|
+
*/
|
|
4
|
+
/** The longest message a contribution may carry, in characters. */
|
|
5
|
+
export const MAX_MESSAGE_LENGTH = 5000;
|
|
6
|
+
/** The most messages one catalog of a contribution may carry. */
|
|
7
|
+
export const MAX_MESSAGES_PER_CATALOG = 2000;
|
|
8
|
+
/** The most catalogs one contribution may carry. */
|
|
9
|
+
export const MAX_CATALOGS = 32;
|
|
10
|
+
/** The longest name a translator may be credited under. */
|
|
11
|
+
export const MAX_CONTRIBUTOR_LENGTH = 100;
|
|
12
|
+
/** The longest note a translator may leave for the reviewer. */
|
|
13
|
+
export const MAX_NOTE_LENGTH = 1000;
|
|
14
|
+
//# sourceMappingURL=contribution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contribution.js","sourceRoot":"","sources":["../../../src/translate/core/contribution.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,mEAAmE;AACnE,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAEvC,iEAAiE;AACjE,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAE7C,oDAAoD;AACpD,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AAE/B,2DAA2D;AAC3D,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAE1C,gEAAgE;AAChE,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { languageName } from '../../language/core/languageName.ts';
|
|
2
|
+
export { isLanguageTag } from '../../language/core/languageParam.ts';
|
|
3
|
+
export type { CatalogSource, MessageRef, Messages } from './catalog.ts';
|
|
4
|
+
export { SOURCE_LOCALE, catalogFile, isCatalogDirectory, ownMessage, } from './catalog.ts';
|
|
5
|
+
export type { MessageProblem, MessageProblemKind } from './checkTranslation.ts';
|
|
6
|
+
export { checkTranslation, messageArguments } from './checkTranslation.ts';
|
|
7
|
+
export type { Contribution, ContributionCatalog, ContributionProblem, ContributionPullRequest, ContributionRejection, ContributionResult, } from './contribution.ts';
|
|
8
|
+
export { MAX_CATALOGS, MAX_CONTRIBUTOR_LENGTH, MAX_MESSAGES_PER_CATALOG, MAX_MESSAGE_LENGTH, MAX_NOTE_LENGTH, } from './contribution.ts';
|
|
9
|
+
export { encodeMarker, hasMarker, markText, readMarkers, stripMarkers, } from './marker.ts';
|
|
10
|
+
export { changedKeys, mergeMessages, parseMessages, serializeMessages, } from './mergeMessages.ts';
|
|
11
|
+
export type { CatalogSnapshot, MessageValues, TranslateBridge, TranslateSessionOptions, } from './session.ts';
|
|
12
|
+
export { BRIDGE_GLOBAL, BRIDGE_PROTOCOL, TranslateSession } from './session.ts';
|
|
13
|
+
export type { LoadOverlayOptions, StartTranslatingOptions } from './start.ts';
|
|
14
|
+
export { TRANSLATE_ORIGIN, TRANSLATE_PARAM, loadOverlay, readTranslateLocale, startTranslating, } from './start.ts';
|
|
15
|
+
export type { MessageSuggestion, SuggestionKind, SuggestionOptions, TranslatedPair, } from './suggestions.ts';
|
|
16
|
+
export { messageSimilarity, messageSuggestions } from './suggestions.ts';
|
|
17
|
+
export type { TableCell, TranslatableField, TranslatableFieldSize, TranslatableRow, TranslatableTable, } from './tables.ts';
|
|
18
|
+
export { tableCells, tableKey } from './tables.ts';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/translate/core/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,cA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,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Both travel with the catalogs: a server validating a submission and naming
|
|
2
|
+
// the language in a pull request must not have to load the whole of
|
|
3
|
+
// `react-cheminfo/core` to do it.
|
|
4
|
+
export { languageName } from "../../language/core/languageName.js";
|
|
5
|
+
export { isLanguageTag } from "../../language/core/languageParam.js";
|
|
6
|
+
export { SOURCE_LOCALE, catalogFile, isCatalogDirectory, ownMessage, } from "./catalog.js";
|
|
7
|
+
export { checkTranslation, messageArguments } from "./checkTranslation.js";
|
|
8
|
+
export { MAX_CATALOGS, MAX_CONTRIBUTOR_LENGTH, MAX_MESSAGES_PER_CATALOG, MAX_MESSAGE_LENGTH, MAX_NOTE_LENGTH, } from "./contribution.js";
|
|
9
|
+
export { encodeMarker, hasMarker, markText, readMarkers, stripMarkers, } from "./marker.js";
|
|
10
|
+
export { changedKeys, mergeMessages, parseMessages, serializeMessages, } from "./mergeMessages.js";
|
|
11
|
+
export { BRIDGE_GLOBAL, BRIDGE_PROTOCOL, TranslateSession } from "./session.js";
|
|
12
|
+
export { TRANSLATE_ORIGIN, TRANSLATE_PARAM, loadOverlay, readTranslateLocale, startTranslating, } from "./start.js";
|
|
13
|
+
export { messageSimilarity, messageSuggestions } from "./suggestions.js";
|
|
14
|
+
export { tableCells, tableKey } from "./tables.js";
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/translate/core/index.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,oEAAoE;AACpE,kCAAkC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,OAAO,EACL,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,UAAU,GACX,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAS3E,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,wBAAwB,EACxB,kBAAkB,EAClB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,WAAW,EACX,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,WAAW,EACX,aAAa,EACb,aAAa,EACb,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAO5B,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhF,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AAOpB,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAQzE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The invisible mark a message carries while a page is being translated.
|
|
3
|
+
*
|
|
4
|
+
* In translate mode every formatted message is prefixed with its id, written
|
|
5
|
+
* in characters that take no space and join nothing. Whatever the string then
|
|
6
|
+
* becomes — a text node, a `title`, a `placeholder`, a prop handed to a
|
|
7
|
+
* third-party component — the overlay finds it in the DOM and knows which
|
|
8
|
+
* message it is, without any component having been written for it.
|
|
9
|
+
*
|
|
10
|
+
* The digits are the invisible mathematical operators U+2061–U+2064, closed by
|
|
11
|
+
* WORD JOINER U+2060: none of them is whitespace, none joins emoji the way
|
|
12
|
+
* ZERO WIDTH JOINER does, and all are default-ignorable, so fonts draw nothing.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Write a message id as an invisible marker.
|
|
16
|
+
* @param id - The id, a non-negative integer.
|
|
17
|
+
* @returns The marker, to be put in front of the formatted message.
|
|
18
|
+
*/
|
|
19
|
+
export declare function encodeMarker(id: number): string;
|
|
20
|
+
/**
|
|
21
|
+
* Prefix a formatted message with the marker of its id.
|
|
22
|
+
* @param text - The message as it will be shown.
|
|
23
|
+
* @param id - The id of the message.
|
|
24
|
+
* @returns The same text, with the invisible marker in front.
|
|
25
|
+
*/
|
|
26
|
+
export declare function markText(text: string, id: number): string;
|
|
27
|
+
/**
|
|
28
|
+
* The ids of every message a string carries, in the order they appear.
|
|
29
|
+
* @param text - A text node's data or an attribute's value.
|
|
30
|
+
* @returns The ids; empty when the string holds no marker.
|
|
31
|
+
*/
|
|
32
|
+
export declare function readMarkers(text: string): number[];
|
|
33
|
+
/**
|
|
34
|
+
* Whether a string carries at least one marker.
|
|
35
|
+
* @param text - The string to look at.
|
|
36
|
+
* @returns True when a marker is present.
|
|
37
|
+
*/
|
|
38
|
+
export declare function hasMarker(text: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* The string with every marker removed, as it reads outside translate mode.
|
|
41
|
+
* @param text - A string that may carry markers.
|
|
42
|
+
* @returns The visible text only.
|
|
43
|
+
*/
|
|
44
|
+
export declare function stripMarkers(text: string): string;
|
|
45
|
+
//# sourceMappingURL=marker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marker.d.ts","sourceRoot":"","sources":["../../../src/translate/core/marker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAUH;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAW/C;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAWlD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE/C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The invisible mark a message carries while a page is being translated.
|
|
3
|
+
*
|
|
4
|
+
* In translate mode every formatted message is prefixed with its id, written
|
|
5
|
+
* in characters that take no space and join nothing. Whatever the string then
|
|
6
|
+
* becomes — a text node, a `title`, a `placeholder`, a prop handed to a
|
|
7
|
+
* third-party component — the overlay finds it in the DOM and knows which
|
|
8
|
+
* message it is, without any component having been written for it.
|
|
9
|
+
*
|
|
10
|
+
* The digits are the invisible mathematical operators U+2061–U+2064, closed by
|
|
11
|
+
* WORD JOINER U+2060: none of them is whitespace, none joins emoji the way
|
|
12
|
+
* ZERO WIDTH JOINER does, and all are default-ignorable, so fonts draw nothing.
|
|
13
|
+
*/
|
|
14
|
+
const DIGITS = ['', '', '', ''];
|
|
15
|
+
const END = '';
|
|
16
|
+
const BASE = DIGITS.length;
|
|
17
|
+
const FIRST_DIGIT = 0x20_61;
|
|
18
|
+
const MARKER = /[-]+/;
|
|
19
|
+
const MARKERS = /[-]+/g;
|
|
20
|
+
/**
|
|
21
|
+
* Write a message id as an invisible marker.
|
|
22
|
+
* @param id - The id, a non-negative integer.
|
|
23
|
+
* @returns The marker, to be put in front of the formatted message.
|
|
24
|
+
*/
|
|
25
|
+
export function encodeMarker(id) {
|
|
26
|
+
if (!Number.isSafeInteger(id) || id < 0) {
|
|
27
|
+
throw new RangeError(`a marker id is a non-negative integer, got ${id}`);
|
|
28
|
+
}
|
|
29
|
+
let digits = '';
|
|
30
|
+
let rest = id;
|
|
31
|
+
do {
|
|
32
|
+
digits = `${DIGITS[rest % BASE]}${digits}`;
|
|
33
|
+
rest = Math.floor(rest / BASE);
|
|
34
|
+
} while (rest > 0);
|
|
35
|
+
return `${digits}${END}`;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Prefix a formatted message with the marker of its id.
|
|
39
|
+
* @param text - The message as it will be shown.
|
|
40
|
+
* @param id - The id of the message.
|
|
41
|
+
* @returns The same text, with the invisible marker in front.
|
|
42
|
+
*/
|
|
43
|
+
export function markText(text, id) {
|
|
44
|
+
return `${encodeMarker(id)}${text}`;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The ids of every message a string carries, in the order they appear.
|
|
48
|
+
* @param text - A text node's data or an attribute's value.
|
|
49
|
+
* @returns The ids; empty when the string holds no marker.
|
|
50
|
+
*/
|
|
51
|
+
export function readMarkers(text) {
|
|
52
|
+
const ids = [];
|
|
53
|
+
for (const match of text.matchAll(MARKERS)) {
|
|
54
|
+
const marker = match[0];
|
|
55
|
+
let id = 0;
|
|
56
|
+
for (let index = 0; index < marker.length - 1; index++) {
|
|
57
|
+
id = id * BASE + (marker.codePointAt(index) ?? FIRST_DIGIT) - FIRST_DIGIT;
|
|
58
|
+
}
|
|
59
|
+
ids.push(id);
|
|
60
|
+
}
|
|
61
|
+
return ids;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Whether a string carries at least one marker.
|
|
65
|
+
* @param text - The string to look at.
|
|
66
|
+
* @returns True when a marker is present.
|
|
67
|
+
*/
|
|
68
|
+
export function hasMarker(text) {
|
|
69
|
+
return MARKER.test(text);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The string with every marker removed, as it reads outside translate mode.
|
|
73
|
+
* @param text - A string that may carry markers.
|
|
74
|
+
* @returns The visible text only.
|
|
75
|
+
*/
|
|
76
|
+
export function stripMarkers(text) {
|
|
77
|
+
return text.replaceAll(MARKERS, '');
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=marker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marker.js","sourceRoot":"","sources":["../../../src/translate/core/marker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,MAAM,GAAG,CAAC,GAAG,EA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AAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;YACvD,EAAE,GAAG,EAAE,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,WAAW,CAAC,GAAG,WAAW,CAAC;QAC5E,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Messages } from './catalog.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Merge a translator's messages into a locale file.
|
|
4
|
+
*
|
|
5
|
+
* Keys come out in the order of the English file, so a pull request's diff is
|
|
6
|
+
* the lines that changed and nothing else; keys the English file no longer has
|
|
7
|
+
* are kept, last, because removing them is not the translator's decision.
|
|
8
|
+
* @param source - The English messages, whose order is followed.
|
|
9
|
+
* @param existing - The locale file as it is in the repository.
|
|
10
|
+
* @param updates - The messages the translator wrote.
|
|
11
|
+
* @returns The merged messages.
|
|
12
|
+
*/
|
|
13
|
+
export declare function mergeMessages(source: Messages, existing: Messages, updates: Messages): Messages;
|
|
14
|
+
/**
|
|
15
|
+
* The keys whose message an update actually changes.
|
|
16
|
+
* @param existing - The locale file as it is in the repository.
|
|
17
|
+
* @param updates - The messages the translator wrote.
|
|
18
|
+
* @returns The keys that differ, in the order of the updates.
|
|
19
|
+
*/
|
|
20
|
+
export declare function changedKeys(existing: Messages, updates: Messages): string[];
|
|
21
|
+
/**
|
|
22
|
+
* Write messages the way a catalog file is committed: two-space JSON with a
|
|
23
|
+
* final newline, which is also what Prettier leaves untouched.
|
|
24
|
+
* @param messages - The messages.
|
|
25
|
+
* @returns The file content.
|
|
26
|
+
*/
|
|
27
|
+
export declare function serializeMessages(messages: Messages): string;
|
|
28
|
+
/**
|
|
29
|
+
* Read a catalog file, refusing anything but a flat object of strings.
|
|
30
|
+
* @param text - The file content.
|
|
31
|
+
* @returns The messages.
|
|
32
|
+
* @throws {TypeError} When the content is not a flat object of strings.
|
|
33
|
+
*/
|
|
34
|
+
export declare function parseMessages(text: string): Messages;
|
|
35
|
+
//# sourceMappingURL=mergeMessages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeMessages.d.ts","sourceRoot":"","sources":["../../../src/translate/core/mergeMessages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG7C;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,QAAQ,EAChB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,QAAQ,GAChB,QAAQ,CAUV;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,GAAG,MAAM,EAAE,CAM3E;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAE5D;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAapD"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { ownMessage } from "./catalog.js";
|
|
2
|
+
/**
|
|
3
|
+
* Merge a translator's messages into a locale file.
|
|
4
|
+
*
|
|
5
|
+
* Keys come out in the order of the English file, so a pull request's diff is
|
|
6
|
+
* the lines that changed and nothing else; keys the English file no longer has
|
|
7
|
+
* are kept, last, because removing them is not the translator's decision.
|
|
8
|
+
* @param source - The English messages, whose order is followed.
|
|
9
|
+
* @param existing - The locale file as it is in the repository.
|
|
10
|
+
* @param updates - The messages the translator wrote.
|
|
11
|
+
* @returns The merged messages.
|
|
12
|
+
*/
|
|
13
|
+
export function mergeMessages(source, existing, updates) {
|
|
14
|
+
const entries = [];
|
|
15
|
+
for (const key of Object.keys(source)) {
|
|
16
|
+
const message = ownMessage(updates, key) ?? ownMessage(existing, key);
|
|
17
|
+
if (message !== undefined)
|
|
18
|
+
entries.push([key, message]);
|
|
19
|
+
}
|
|
20
|
+
for (const [key, message] of Object.entries(existing)) {
|
|
21
|
+
if (!Object.hasOwn(source, key))
|
|
22
|
+
entries.push([key, message]);
|
|
23
|
+
}
|
|
24
|
+
return Object.fromEntries(entries);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The keys whose message an update actually changes.
|
|
28
|
+
* @param existing - The locale file as it is in the repository.
|
|
29
|
+
* @param updates - The messages the translator wrote.
|
|
30
|
+
* @returns The keys that differ, in the order of the updates.
|
|
31
|
+
*/
|
|
32
|
+
export function changedKeys(existing, updates) {
|
|
33
|
+
const keys = [];
|
|
34
|
+
for (const [key, message] of Object.entries(updates)) {
|
|
35
|
+
if (ownMessage(existing, key) !== message)
|
|
36
|
+
keys.push(key);
|
|
37
|
+
}
|
|
38
|
+
return keys;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Write messages the way a catalog file is committed: two-space JSON with a
|
|
42
|
+
* final newline, which is also what Prettier leaves untouched.
|
|
43
|
+
* @param messages - The messages.
|
|
44
|
+
* @returns The file content.
|
|
45
|
+
*/
|
|
46
|
+
export function serializeMessages(messages) {
|
|
47
|
+
return `${JSON.stringify(messages, null, 2)}\n`;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Read a catalog file, refusing anything but a flat object of strings.
|
|
51
|
+
* @param text - The file content.
|
|
52
|
+
* @returns The messages.
|
|
53
|
+
* @throws {TypeError} When the content is not a flat object of strings.
|
|
54
|
+
*/
|
|
55
|
+
export function parseMessages(text) {
|
|
56
|
+
const parsed = JSON.parse(text);
|
|
57
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
58
|
+
throw new TypeError('a catalog file must hold one JSON object');
|
|
59
|
+
}
|
|
60
|
+
const entries = [];
|
|
61
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
62
|
+
if (typeof value !== 'string') {
|
|
63
|
+
throw new TypeError(`the message "${key}" is not a string`);
|
|
64
|
+
}
|
|
65
|
+
entries.push([key, value]);
|
|
66
|
+
}
|
|
67
|
+
return Object.fromEntries(entries);
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=mergeMessages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeMessages.js","sourceRoot":"","sources":["../../../src/translate/core/mergeMessages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,aAAa,CAC3B,MAAgB,EAChB,QAAkB,EAClB,OAAiB;IAEjB,MAAM,OAAO,GAA4B,EAAE,CAAC;IAC5C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,UAAU,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QACtE,IAAI,OAAO,KAAK,SAAS;YAAE,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;IAC1D,CAAC;IACD,KAAK,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACtD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;YAAE,OAAO,CAAC,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IAAI,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;IAC7B,CAAC;IACD,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { CatalogSource, MessageRef, Messages } from './catalog.ts';
|
|
2
|
+
import type { TranslatableTable } from './tables.ts';
|
|
3
|
+
/** The values a message's placeholders are filled with. */
|
|
4
|
+
export type MessageValues = Record<string, string | number | Date>;
|
|
5
|
+
/** The version of the page ↔ overlay protocol this session speaks. */
|
|
6
|
+
export declare const BRIDGE_PROTOCOL = 2;
|
|
7
|
+
/** Where a page in translate mode exposes its session to the overlay. */
|
|
8
|
+
export declare const BRIDGE_GLOBAL = "__cheminfoTranslate";
|
|
9
|
+
/** A catalog as the overlay sees it: the source, what is published, the edits. */
|
|
10
|
+
export interface CatalogSnapshot extends CatalogSource {
|
|
11
|
+
/** The locale file as published with the site. */
|
|
12
|
+
translation: Messages;
|
|
13
|
+
/** The messages edited in the overlay and not yet submitted. */
|
|
14
|
+
drafts: Messages;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* What a page in translate mode offers the overlay. It is the only contract
|
|
18
|
+
* between the two, so an overlay released later still drives a page built
|
|
19
|
+
* earlier as long as the protocol number matches.
|
|
20
|
+
*/
|
|
21
|
+
export interface TranslateBridge {
|
|
22
|
+
/** The protocol version; the overlay refuses a page speaking another. */
|
|
23
|
+
readonly protocol: typeof BRIDGE_PROTOCOL;
|
|
24
|
+
/** The locale being translated into. */
|
|
25
|
+
readonly locale: string;
|
|
26
|
+
/** Every catalog the page registered. */
|
|
27
|
+
catalogs: () => CatalogSnapshot[];
|
|
28
|
+
/**
|
|
29
|
+
* The tables of the page whose rows a translator may write — the element
|
|
30
|
+
* sheet, a list of ions — with the columns that are text rather than
|
|
31
|
+
* measurement. Empty on a page that shows no table.
|
|
32
|
+
*/
|
|
33
|
+
tables: () => TranslatableTable[];
|
|
34
|
+
/** The message a marker found in the DOM stands for. */
|
|
35
|
+
resolveMarker: (id: number) => MessageRef | undefined;
|
|
36
|
+
/** Show an edited message on the page; `undefined` removes the edit. */
|
|
37
|
+
setDraft: (ref: MessageRef, message: string | undefined) => void;
|
|
38
|
+
/** Be told whenever a draft changes; returns the function that stops it. */
|
|
39
|
+
subscribe: (listener: () => void) => () => void;
|
|
40
|
+
}
|
|
41
|
+
/** How a session is set up. */
|
|
42
|
+
export interface TranslateSessionOptions {
|
|
43
|
+
/** The locale messages are shown in. */
|
|
44
|
+
locale: string;
|
|
45
|
+
/** Every catalog the page renders from. */
|
|
46
|
+
catalogs: readonly CatalogSource[];
|
|
47
|
+
/**
|
|
48
|
+
* The published messages of `locale`, by catalog id.
|
|
49
|
+
* @default {}
|
|
50
|
+
*/
|
|
51
|
+
translations?: Readonly<Record<string, Messages>>;
|
|
52
|
+
/**
|
|
53
|
+
* Whether every formatted message carries its invisible marker, which is
|
|
54
|
+
* what translate mode is.
|
|
55
|
+
* @default false
|
|
56
|
+
*/
|
|
57
|
+
marked?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* The tables whose rows are translated, declared so the overlay can offer
|
|
60
|
+
* them as a grid: a cell of a table is rarely on the page being looked at,
|
|
61
|
+
* and 118 of them are never Alt-clicked one by one.
|
|
62
|
+
* @default []
|
|
63
|
+
*/
|
|
64
|
+
tables?: readonly TranslatableTable[];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Formats the messages of a page, and in translate mode lets the overlay edit
|
|
68
|
+
* them live: a draft replaces the published message as soon as it can be
|
|
69
|
+
* formatted, and a draft that cannot is ignored rather than breaking the page.
|
|
70
|
+
*/
|
|
71
|
+
export declare class TranslateSession implements TranslateBridge {
|
|
72
|
+
#private;
|
|
73
|
+
readonly protocol = 2;
|
|
74
|
+
readonly locale: string;
|
|
75
|
+
constructor(options: TranslateSessionOptions);
|
|
76
|
+
/**
|
|
77
|
+
* Increases on every draft change, for a view that re-renders on it.
|
|
78
|
+
* @returns The current version.
|
|
79
|
+
*/
|
|
80
|
+
get version(): number;
|
|
81
|
+
/**
|
|
82
|
+
* Format one message: the draft, else the published translation, else the
|
|
83
|
+
* English message — the first that passes its check against the English
|
|
84
|
+
* one and formats. A draft that drops a placeholder formats without error,
|
|
85
|
+
* so the check, not the formatting, is what keeps it off the page.
|
|
86
|
+
* @param catalogId - The catalog the message belongs to.
|
|
87
|
+
* @param key - The key of the message.
|
|
88
|
+
* @param values - What the placeholders are filled with.
|
|
89
|
+
* @returns The text to show; the key itself when no catalog has it.
|
|
90
|
+
*/
|
|
91
|
+
format(catalogId: string, key: string, values?: MessageValues): string;
|
|
92
|
+
catalogs(): CatalogSnapshot[];
|
|
93
|
+
/**
|
|
94
|
+
* The tables whose rows a translator may write.
|
|
95
|
+
* @returns One entry per table the page declared.
|
|
96
|
+
*/
|
|
97
|
+
tables(): TranslatableTable[];
|
|
98
|
+
resolveMarker(id: number): MessageRef | undefined;
|
|
99
|
+
setDraft(ref: MessageRef, message: string | undefined): void;
|
|
100
|
+
subscribe(listener: () => void): () => void;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/translate/core/session.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAIxE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,2DAA2D;AAC3D,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,CAAC;AAEnE,sEAAsE;AACtE,eAAO,MAAM,eAAe,IAAI,CAAC;AAEjC,yEAAyE;AACzE,eAAO,MAAM,aAAa,wBAAwB,CAAC;AAEnD,kFAAkF;AAClF,MAAM,WAAW,eAAgB,S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