@antelopejs/dms-lang 0.0.7 → 0.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/README.md +12 -6
- package/dist/pages/actions.d.ts +7 -0
- package/dist/pages/actions.js +15 -0
- package/dist/pages/actions.js.map +1 -0
- package/dist/pages/component-action.d.ts +2 -0
- package/dist/pages/component-action.js +10 -0
- package/dist/pages/component-action.js.map +1 -0
- package/dist/pages/header-actions.d.ts +9 -0
- package/dist/pages/header-actions.js +146 -0
- package/dist/pages/header-actions.js.map +1 -0
- package/dist/pages/index.d.ts +6 -0
- package/dist/pages/index.js +6 -0
- package/dist/pages/index.js.map +1 -1
- package/dist/pages/language.d.ts +10 -0
- package/dist/pages/language.js +89 -0
- package/dist/pages/language.js.map +1 -0
- package/dist/pages/languages-table.d.ts +2 -0
- package/dist/pages/languages-table.js +120 -0
- package/dist/pages/languages-table.js.map +1 -0
- package/dist/pages/module.d.ts +7 -1
- package/dist/pages/module.js +28 -2
- package/dist/pages/module.js.map +1 -1
- package/dist/pages/overview.d.ts +2 -1
- package/dist/pages/overview.js +83 -8
- package/dist/pages/overview.js.map +1 -1
- package/dist/pages/page-actions.d.ts +6 -0
- package/dist/pages/page-actions.js +10 -0
- package/dist/pages/page-actions.js.map +1 -0
- package/dist/pages/quick-actions.d.ts +1 -0
- package/dist/pages/quick-actions.js +56 -0
- package/dist/pages/quick-actions.js.map +1 -0
- package/dist/pages/translations.d.ts +7 -1
- package/dist/pages/translations.js +47 -10
- package/dist/pages/translations.js.map +1 -1
- package/dist/pages/workspace-guard.d.ts +1 -0
- package/dist/pages/workspace-guard.js +35 -0
- package/dist/pages/workspace-guard.js.map +1 -0
- package/dist/pages/workspace.d.ts +18 -0
- package/dist/pages/workspace.js +162 -0
- package/dist/pages/workspace.js.map +1 -0
- package/dist/pages/workspaces.d.ts +14 -0
- package/dist/pages/workspaces.js +88 -0
- package/dist/pages/workspaces.js.map +1 -0
- package/dist/routes/publicLocales.d.ts +3 -2
- package/dist/routes/publicLocales.js +39 -18
- package/dist/routes/publicLocales.js.map +1 -1
- package/dist/routes/translations.d.ts +59 -63
- package/dist/routes/translations.js +400 -119
- package/dist/routes/translations.js.map +1 -1
- package/dist/utils/announce.d.ts +9 -0
- package/dist/utils/announce.js +29 -0
- package/dist/utils/announce.js.map +1 -0
- package/dist/utils/blocks.d.ts +8 -0
- package/dist/utils/blocks.js +213 -0
- package/dist/utils/blocks.js.map +1 -0
- package/dist/utils/body.d.ts +1 -0
- package/dist/utils/body.js +21 -0
- package/dist/utils/body.js.map +1 -0
- package/dist/utils/cache.d.ts +3 -0
- package/dist/utils/cache.js +32 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/catalog.d.ts +7 -0
- package/dist/utils/catalog.js +62 -0
- package/dist/utils/catalog.js.map +1 -0
- package/dist/utils/constants.d.ts +6 -0
- package/dist/utils/constants.js +10 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/coverage.d.ts +2 -0
- package/dist/utils/coverage.js +11 -0
- package/dist/utils/coverage.js.map +1 -0
- package/dist/utils/dialogs.d.ts +7 -0
- package/dist/utils/dialogs.js +103 -0
- package/dist/utils/dialogs.js.map +1 -0
- package/dist/utils/errors.d.ts +40 -0
- package/dist/utils/errors.js +60 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/export.d.ts +17 -0
- package/dist/utils/export.js +129 -0
- package/dist/utils/export.js.map +1 -0
- package/dist/utils/json.d.ts +10 -1
- package/dist/utils/json.js +127 -19
- package/dist/utils/json.js.map +1 -1
- package/dist/utils/key-stores.d.ts +3 -0
- package/dist/utils/key-stores.js +24 -0
- package/dist/utils/key-stores.js.map +1 -0
- package/dist/utils/keys.d.ts +23 -0
- package/dist/utils/keys.js +252 -0
- package/dist/utils/keys.js.map +1 -0
- package/dist/utils/languages.d.ts +27 -0
- package/dist/utils/languages.js +121 -0
- package/dist/utils/languages.js.map +1 -0
- package/dist/utils/locale-codes.d.ts +5 -0
- package/dist/utils/locale-codes.js +56 -0
- package/dist/utils/locale-codes.js.map +1 -0
- package/dist/utils/locale-discovery.d.ts +1 -0
- package/dist/utils/locale-discovery.js +19 -1
- package/dist/utils/locale-discovery.js.map +1 -1
- package/dist/utils/message-check.d.ts +1 -0
- package/dist/utils/message-check.js +93 -0
- package/dist/utils/message-check.js.map +1 -0
- package/dist/utils/message-syntax.d.ts +6 -0
- package/dist/utils/message-syntax.js +38 -0
- package/dist/utils/message-syntax.js.map +1 -0
- package/dist/utils/namespaces.d.ts +12 -0
- package/dist/utils/namespaces.js +52 -0
- package/dist/utils/namespaces.js.map +1 -0
- package/dist/utils/notices.d.ts +4 -0
- package/dist/utils/notices.js +60 -0
- package/dist/utils/notices.js.map +1 -0
- package/dist/utils/own.d.ts +2 -3
- package/dist/utils/own.js +17 -57
- package/dist/utils/own.js.map +1 -1
- package/dist/utils/public-url.d.ts +8 -0
- package/dist/utils/public-url.js +87 -0
- package/dist/utils/public-url.js.map +1 -0
- package/dist/utils/registry.d.ts +3 -1
- package/dist/utils/registry.js +26 -10
- package/dist/utils/registry.js.map +1 -1
- package/dist/utils/resolve.d.ts +18 -15
- package/dist/utils/resolve.js +98 -151
- package/dist/utils/resolve.js.map +1 -1
- package/dist/utils/review.d.ts +5 -0
- package/dist/utils/review.js +64 -0
- package/dist/utils/review.js.map +1 -0
- package/dist/utils/snippets.d.ts +7 -0
- package/dist/utils/snippets.js +129 -0
- package/dist/utils/snippets.js.map +1 -0
- package/dist/utils/summary.d.ts +23 -0
- package/dist/utils/summary.js +65 -0
- package/dist/utils/summary.js.map +1 -0
- package/dist/utils/tree.d.ts +2 -17
- package/dist/utils/tree.js +21 -126
- package/dist/utils/tree.js.map +1 -1
- package/dist/utils/workspaces.d.ts +45 -15
- package/dist/utils/workspaces.js +256 -164
- package/dist/utils/workspaces.js.map +1 -1
- package/dist/validation/key.schema.d.ts +71 -0
- package/dist/validation/key.schema.js +67 -0
- package/dist/validation/key.schema.js.map +1 -0
- package/dist/validation/query.schema.d.ts +17 -0
- package/dist/validation/query.schema.js +44 -0
- package/dist/validation/query.schema.js.map +1 -0
- package/dist/validation/validate.d.ts +2 -0
- package/dist/validation/validate.js +24 -0
- package/dist/validation/validate.js.map +1 -0
- package/dist/validation/workspace.schema.d.ts +145 -0
- package/dist/validation/workspace.schema.js +83 -0
- package/dist/validation/workspace.schema.js.map +1 -0
- package/frontend-vue/app/build/components/KeyAddModal.vue +340 -0
- package/frontend-vue/app/build/components/KeyEditorDrawer.vue +951 -0
- package/frontend-vue/app/build/components/KeyRenameModal.vue +172 -0
- package/frontend-vue/app/build/components/LanguageAddModal.vue +199 -0
- package/frontend-vue/app/build/components/LanguagePicker.vue +233 -0
- package/frontend-vue/app/build/components/LocaleTile.vue +52 -0
- package/frontend-vue/app/build/components/PlaceholderText.vue +42 -0
- package/frontend-vue/app/build/components/ShortcutKbds.vue +22 -0
- package/frontend-vue/app/build/components/WorkspaceCreateModal.vue +193 -0
- package/frontend-vue/app/build/components/WorkspaceRenameModal.vue +107 -0
- package/frontend-vue/app/build/components/form/FormFieldRow.vue +70 -0
- package/frontend-vue/app/build/components/form/FormRows.vue +25 -0
- package/frontend-vue/app/build/components/form/WorkspaceDetailsFields.vue +44 -0
- package/frontend-vue/app/build/components/matrix/MatrixCell.vue +488 -0
- package/frontend-vue/app/build/components/matrix/MatrixColumns.vue +177 -0
- package/frontend-vue/app/build/components/matrix/MatrixGroupHeader.vue +57 -0
- package/frontend-vue/app/build/components/matrix/MatrixKeyCell.vue +83 -0
- package/frontend-vue/app/build/components/matrix/MatrixToolbar.vue +167 -0
- package/frontend-vue/app/build/components/queue/QueueActions.vue +60 -0
- package/frontend-vue/app/build/components/queue/QueueDone.vue +185 -0
- package/frontend-vue/app/build/components/queue/QueueEditor.vue +374 -0
- package/frontend-vue/app/build/components/queue/QueueHeader.vue +162 -0
- package/frontend-vue/app/build/components/queue/QueueUpNext.vue +61 -0
- package/frontend-vue/app/build/composables/useCellEditor.ts +324 -0
- package/frontend-vue/app/build/composables/useCellMoves.ts +155 -0
- package/frontend-vue/app/build/composables/useCellSaves.ts +339 -0
- package/frontend-vue/app/build/composables/useKeyPanel.ts +284 -0
- package/frontend-vue/app/build/composables/useKeySaves.ts +280 -0
- package/frontend-vue/app/build/composables/useMatrixFilters.ts +213 -0
- package/frontend-vue/app/build/composables/useMatrixRows.ts +104 -0
- package/frontend-vue/app/build/composables/useMatrixView.ts +181 -0
- package/frontend-vue/app/build/composables/useQueueContext.ts +31 -0
- package/frontend-vue/app/build/composables/useQueueEditing.ts +53 -0
- package/frontend-vue/app/build/composables/useQueueOrphans.ts +54 -0
- package/frontend-vue/app/build/composables/useQueueSave.ts +290 -0
- package/frontend-vue/app/build/composables/useQueueShortcuts.ts +106 -0
- package/frontend-vue/app/build/composables/useQueueToasts.ts +99 -0
- package/frontend-vue/app/components/LanguageNamespaces.vue +77 -0
- package/frontend-vue/app/components/NamespaceCoverage.vue +222 -0
- package/frontend-vue/app/components/TranslationMatrix.vue +809 -0
- package/frontend-vue/app/components/TranslationQueue.vue +212 -0
- package/frontend-vue/app/components/WorkspaceDangerZone.vue +81 -0
- package/frontend-vue/app/components/WorkspaceGeneral.vue +232 -0
- package/frontend-vue/app/components/WorkspaceList.vue +454 -0
- package/frontend-vue/app/components/WorkspaceScope.vue +384 -0
- package/frontend-vue/app/composables/translation/useFirstRun.ts +8 -0
- package/frontend-vue/app/composables/translation/useI18nWorkspaces.ts +221 -133
- package/frontend-vue/app/composables/translation/useKeyActions.ts +224 -0
- package/frontend-vue/app/composables/translation/useLangFormat.ts +10 -0
- package/frontend-vue/app/composables/translation/useLangLinks.ts +80 -0
- package/frontend-vue/app/composables/translation/useLanguageActions.ts +159 -0
- package/frontend-vue/app/composables/translation/useLanguageQueue.ts +232 -0
- package/frontend-vue/app/composables/translation/useLocaleNames.ts +166 -0
- package/frontend-vue/app/composables/translation/useMutationToast.ts +51 -17
- package/frontend-vue/app/composables/translation/useQueueDrafts.ts +115 -0
- package/frontend-vue/app/composables/translation/useQueueSession.ts +182 -0
- package/frontend-vue/app/composables/translation/useServedConfirm.ts +152 -0
- package/frontend-vue/app/composables/translation/useWorkspaceActions.ts +259 -0
- package/frontend-vue/app/composables/translation/useWorkspaceContext.ts +46 -15
- package/frontend-vue/app/composables/translation/useWorkspaceFlat.ts +322 -70
- package/frontend-vue/app/composables/translation/useWorkspaceNameCheck.ts +55 -0
- package/frontend-vue/app/composables/translation/useWorkspaceRoute.ts +129 -0
- package/frontend-vue/app/config/shortcuts-registry.ts +72 -0
- package/frontend-vue/app/types/lang.ts +130 -0
- package/frontend-vue/app/utils/boundedCache.ts +22 -0
- package/frontend-vue/app/utils/download.ts +16 -0
- package/frontend-vue/app/utils/keySaveErrors.ts +61 -0
- package/frontend-vue/app/utils/keySaves.ts +108 -0
- package/frontend-vue/app/utils/languages.ts +272 -0
- package/frontend-vue/app/utils/matrixExport.ts +47 -0
- package/frontend-vue/app/utils/queueDrafts.ts +115 -0
- package/frontend-vue/app/utils/queuePass.ts +145 -0
- package/frontend-vue/app/utils/queueView.ts +22 -0
- package/frontend-vue/app/utils/shortcuts.ts +75 -0
- package/frontend-vue/app/utils/translations.ts +756 -0
- package/frontend-vue/app/utils/workspaceBackup.ts +119 -0
- package/frontend-vue/app/utils/workspaces.ts +45 -0
- package/frontend-vue/dms.frontend.build.ts +5 -0
- package/frontend-vue/dms.frontend.ts +9 -20
- package/frontend-vue/i18n/locales/lang-en-GB.json +792 -69
- package/frontend-vue/i18n/locales/lang-fr-FR.json +792 -69
- package/frontend-vue/package.json +8 -6
- package/package.json +8 -6
- package/dist/utils/mutations.d.ts +0 -3
- package/dist/utils/mutations.js +0 -35
- package/dist/utils/mutations.js.map +0 -1
- package/frontend-vue/app/build/components/pages/lang/TranslationMatrix.vue +0 -284
- package/frontend-vue/app/components/LanguageAddModal.vue +0 -78
- package/frontend-vue/app/components/WorkspaceEndpoint.vue +0 -29
- package/frontend-vue/app/components/WorkspaceSelector.vue +0 -180
- package/frontend-vue/app/components/WorkspaceStatus.vue +0 -24
- package/frontend-vue/app/composables/translation/useLanguageCatalog.ts +0 -90
- package/frontend-vue/app/composables/translation/useLocaleMeta.ts +0 -18
- package/frontend-vue/app/composables/translation/useTranslationProgress.ts +0 -73
- package/frontend-vue/app/custom-pages/lang/overview.vue +0 -397
- package/frontend-vue/app/custom-pages/lang/translations.vue +0 -498
- package/frontend-vue/app/plugins/workspace-sidebar-widget.ts +0 -12
package/dist/utils/resolve.js
CHANGED
|
@@ -1,98 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
5
|
-
exports.resolveTranslationsByPath = resolveTranslationsByPath;
|
|
3
|
+
exports.needsReview = needsReview;
|
|
4
|
+
exports.isRowMissing = isRowMissing;
|
|
6
5
|
exports.resolveFlat = resolveFlat;
|
|
7
|
-
exports.
|
|
6
|
+
exports.flatCounts = flatCounts;
|
|
7
|
+
exports.resolveRow = resolveRow;
|
|
8
|
+
const cache_1 = require("./cache");
|
|
9
|
+
const catalog_1 = require("./catalog");
|
|
10
|
+
const coverage_1 = require("./coverage");
|
|
11
|
+
const message_check_1 = require("./message-check");
|
|
8
12
|
const registry_1 = require("./registry");
|
|
13
|
+
const review_1 = require("./review");
|
|
9
14
|
const tree_1 = require("./tree");
|
|
10
15
|
const workspaces_1 = require("./workspaces");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
Object.defineProperty(exports, "workspaceKind", { enumerable: true, get: function () { return workspaces_1.workspaceKind; } });
|
|
15
|
-
function unionKeys(messages) {
|
|
16
|
-
let union = {};
|
|
17
|
-
for (const localeMessages of Object.values(messages)) {
|
|
18
|
-
union = (0, tree_1.deepMerge)(union, localeMessages);
|
|
19
|
-
}
|
|
20
|
-
return union;
|
|
21
|
-
}
|
|
22
|
-
function mergedPresence(own, external) {
|
|
23
|
-
const presence = {};
|
|
24
|
-
for (const locale of (0, registry_1.getLocaleCodes)("own")) {
|
|
25
|
-
presence[locale] = (0, tree_1.deepMerge)(external[locale] ?? {}, own[locale] ?? {});
|
|
26
|
-
}
|
|
27
|
-
return presence;
|
|
28
|
-
}
|
|
29
|
-
function ownData(_workspace, fallbackDefaultLocale) {
|
|
30
|
-
const own = (0, registry_1.loadMessages)("own");
|
|
31
|
-
const external = (0, registry_1.loadMessages)("external");
|
|
32
|
-
const presence = mergedPresence(own, external);
|
|
33
|
-
const structure = { [fallbackDefaultLocale]: unionKeys(own) };
|
|
34
|
-
return (0, tree_1.buildTranslationData)(structure, fallbackDefaultLocale, presence);
|
|
35
|
-
}
|
|
36
|
-
function ownByPath(_workspace, path) {
|
|
37
|
-
const own = (0, registry_1.loadMessages)("own");
|
|
38
|
-
const external = (0, registry_1.loadMessages)("external");
|
|
39
|
-
const translations = {};
|
|
40
|
-
const inherited = {};
|
|
41
|
-
for (const locale of (0, registry_1.getLocaleCodes)("own")) {
|
|
42
|
-
translations[locale] = (0, tree_1.getValueAtPath)(own[locale], path);
|
|
43
|
-
inherited[locale] = (0, tree_1.getValueAtPath)(external[locale], path);
|
|
44
|
-
}
|
|
45
|
-
return { translations, inherited };
|
|
46
|
-
}
|
|
47
|
-
function modulesData(_workspace, fallbackDefaultLocale) {
|
|
48
|
-
const external = (0, registry_1.loadMessages)("external");
|
|
49
|
-
const defaultLocale = external[fallbackDefaultLocale]
|
|
50
|
-
? fallbackDefaultLocale
|
|
51
|
-
: (Object.keys(external)[0] ?? fallbackDefaultLocale);
|
|
52
|
-
return (0, tree_1.buildTranslationData)(external, defaultLocale);
|
|
16
|
+
function keysOf(context) {
|
|
17
|
+
const { [context.defaultLocale]: base, ...others } = context.presence;
|
|
18
|
+
return (0, tree_1.deepMerge)(base ?? {}, (0, tree_1.unionKeys)(others));
|
|
53
19
|
}
|
|
54
|
-
function
|
|
20
|
+
function ownFlatContext() {
|
|
55
21
|
return {
|
|
56
|
-
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
function addedData(workspace) {
|
|
60
|
-
const manifest = (0, workspaces_1.getWorkspaceManifest)(workspace);
|
|
61
|
-
return (0, tree_1.buildTranslationData)((0, workspaces_1.loadWorkspaceMessages)(workspace), manifest.defaultLocale);
|
|
62
|
-
}
|
|
63
|
-
function addedByPath(workspace, path) {
|
|
64
|
-
return {
|
|
65
|
-
translations: (0, tree_1.extractTranslationsByPath)((0, workspaces_1.loadWorkspaceMessages)(workspace), path),
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
const RESOLVERS = {
|
|
69
|
-
default: { data: ownData, byPath: ownByPath },
|
|
70
|
-
modules: { data: modulesData, byPath: modulesByPath },
|
|
71
|
-
added: { data: addedData, byPath: addedByPath },
|
|
72
|
-
};
|
|
73
|
-
function resolveTranslationData(workspace, fallbackDefaultLocale) {
|
|
74
|
-
return RESOLVERS[(0, workspaces_1.workspaceKind)(workspace)].data(workspace, fallbackDefaultLocale);
|
|
75
|
-
}
|
|
76
|
-
function resolveTranslationsByPath(workspace, path) {
|
|
77
|
-
return RESOLVERS[(0, workspaces_1.workspaceKind)(workspace)].byPath(workspace, path);
|
|
78
|
-
}
|
|
79
|
-
function ownFlatContext(_workspace, fallbackDefaultLocale) {
|
|
80
|
-
return {
|
|
81
|
-
defaultLocale: fallbackDefaultLocale,
|
|
22
|
+
defaultLocale: (0, catalog_1.projectBaseLocale)(),
|
|
82
23
|
locales: (0, registry_1.getLocaleCodes)("own"),
|
|
83
24
|
presence: (0, registry_1.loadMessages)("own"),
|
|
84
25
|
inherited: (0, registry_1.loadMessages)("external"),
|
|
85
26
|
};
|
|
86
27
|
}
|
|
87
|
-
function modulesFlatContext(
|
|
88
|
-
const external = (0, registry_1.loadMessages)("external");
|
|
89
|
-
const defaultLocale = external[fallbackDefaultLocale]
|
|
90
|
-
? fallbackDefaultLocale
|
|
91
|
-
: (Object.keys(external)[0] ?? fallbackDefaultLocale);
|
|
28
|
+
function modulesFlatContext() {
|
|
92
29
|
return {
|
|
93
|
-
defaultLocale,
|
|
30
|
+
defaultLocale: (0, catalog_1.modulesBaseLocale)(),
|
|
94
31
|
locales: (0, registry_1.getLocaleCodes)("external"),
|
|
95
|
-
presence: external,
|
|
32
|
+
presence: (0, registry_1.loadMessages)("external"),
|
|
33
|
+
overrides: (0, registry_1.loadMessages)("own"),
|
|
96
34
|
};
|
|
97
35
|
}
|
|
98
36
|
function addedFlatContext(workspace) {
|
|
@@ -101,6 +39,7 @@ function addedFlatContext(workspace) {
|
|
|
101
39
|
defaultLocale: manifest.defaultLocale,
|
|
102
40
|
locales: manifest.locales.map((locale) => locale.code),
|
|
103
41
|
presence: (0, workspaces_1.loadWorkspaceMessages)(workspace),
|
|
42
|
+
sources: manifest.sources,
|
|
104
43
|
};
|
|
105
44
|
}
|
|
106
45
|
const FLAT_CONTEXTS = {
|
|
@@ -108,6 +47,9 @@ const FLAT_CONTEXTS = {
|
|
|
108
47
|
modules: modulesFlatContext,
|
|
109
48
|
added: addedFlatContext,
|
|
110
49
|
};
|
|
50
|
+
function contextOf(workspace) {
|
|
51
|
+
return FLAT_CONTEXTS[(0, workspaces_1.workspaceKind)(workspace)](workspace);
|
|
52
|
+
}
|
|
111
53
|
function valuesAtPath(messages, locales, path) {
|
|
112
54
|
const values = {};
|
|
113
55
|
for (const locale of locales) {
|
|
@@ -116,88 +58,93 @@ function valuesAtPath(messages, locales, path) {
|
|
|
116
58
|
}
|
|
117
59
|
return values;
|
|
118
60
|
}
|
|
119
|
-
function
|
|
61
|
+
function presentValues(values) {
|
|
62
|
+
return Object.fromEntries(Object.entries(values).filter(([, value]) => !(0, tree_1.isMissing)(value)));
|
|
63
|
+
}
|
|
64
|
+
function addOverrides(row, context) {
|
|
65
|
+
if (!context.overrides)
|
|
66
|
+
return;
|
|
67
|
+
const overrides = presentValues(valuesAtPath(context.overrides, context.locales, row.key));
|
|
68
|
+
row.overridden = Object.keys(overrides).length > 0;
|
|
69
|
+
if (row.overridden)
|
|
70
|
+
row.overrides = overrides;
|
|
71
|
+
}
|
|
72
|
+
function issueLocales(context, row) {
|
|
73
|
+
const base = row.values[context.defaultLocale];
|
|
74
|
+
return context.locales.filter((locale) => (0, message_check_1.hasMessageIssue)(locale === context.defaultLocale ? "" : base, row.values[locale]));
|
|
75
|
+
}
|
|
76
|
+
function buildFlatRow(context, key) {
|
|
77
|
+
const row = {
|
|
78
|
+
key,
|
|
79
|
+
values: valuesAtPath(context.presence, context.locales, key),
|
|
80
|
+
};
|
|
81
|
+
if (context.inherited) {
|
|
82
|
+
row.inherited = valuesAtPath(context.inherited, context.locales, key);
|
|
83
|
+
}
|
|
84
|
+
addOverrides(row, context);
|
|
85
|
+
const outdated = (0, review_1.outdatedLocales)(context.sources, context.presence, context.defaultLocale, key);
|
|
86
|
+
if (outdated.length > 0)
|
|
87
|
+
row.outdated = outdated;
|
|
88
|
+
const issues = issueLocales(context, row);
|
|
89
|
+
if (issues.length > 0)
|
|
90
|
+
row.issues = issues;
|
|
91
|
+
return row;
|
|
92
|
+
}
|
|
93
|
+
function needsReview(row, locale) {
|
|
94
|
+
return ((row.issues?.includes(locale) ?? false) ||
|
|
95
|
+
(row.outdated?.includes(locale) ?? false));
|
|
96
|
+
}
|
|
97
|
+
function isRowMissing(row, locale) {
|
|
98
|
+
return (0, tree_1.isMissing)(row.values[locale]) && (0, tree_1.isMissing)(row.inherited?.[locale]);
|
|
99
|
+
}
|
|
100
|
+
function countMissing(rows, locale) {
|
|
101
|
+
return rows.filter((row) => isRowMissing(row, locale)).length;
|
|
102
|
+
}
|
|
103
|
+
function summarizeRows(context, rows) {
|
|
120
104
|
const localeMissing = {};
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
continue;
|
|
125
|
-
}
|
|
126
|
-
let missing = 0;
|
|
127
|
-
for (const row of rows) {
|
|
128
|
-
if ((0, tree_1.isMissing)(row.values[locale]))
|
|
129
|
-
missing += 1;
|
|
130
|
-
}
|
|
105
|
+
const localeProgress = {};
|
|
106
|
+
for (const locale of context.locales) {
|
|
107
|
+
const missing = countMissing(rows, locale);
|
|
131
108
|
localeMissing[locale] = missing;
|
|
109
|
+
localeProgress[locale] = (0, coverage_1.coveragePercent)(rows.length - missing, rows.length);
|
|
132
110
|
}
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
function resolveFlat(workspace, fallbackDefaultLocale) {
|
|
136
|
-
const data = resolveTranslationData(workspace, fallbackDefaultLocale);
|
|
137
|
-
const context = FLAT_CONTEXTS[(0, workspaces_1.workspaceKind)(workspace)](workspace, fallbackDefaultLocale);
|
|
138
|
-
const rows = (0, tree_1.collectLeafPaths)(data.tree).map((key) => {
|
|
139
|
-
const row = {
|
|
140
|
-
key,
|
|
141
|
-
values: valuesAtPath(context.presence, context.locales, key),
|
|
142
|
-
};
|
|
143
|
-
if (context.inherited) {
|
|
144
|
-
row.inherited = valuesAtPath(context.inherited, context.locales, key);
|
|
145
|
-
}
|
|
146
|
-
return row;
|
|
147
|
-
});
|
|
148
|
-
const localeMissing = computeLocaleMissing(rows, context.locales, context.defaultLocale);
|
|
111
|
+
const targets = context.locales.filter((locale) => locale !== context.defaultLocale);
|
|
149
112
|
return {
|
|
150
113
|
defaultLocale: context.defaultLocale,
|
|
151
114
|
locales: context.locales,
|
|
152
115
|
rows,
|
|
153
|
-
localeProgress
|
|
116
|
+
localeProgress,
|
|
154
117
|
localeMissing,
|
|
155
|
-
totalKeys:
|
|
118
|
+
totalKeys: rows.length,
|
|
119
|
+
baseMissing: localeMissing[context.defaultLocale] ?? 0,
|
|
120
|
+
incompleteKeys: rows.filter((row) => targets.some((locale) => isRowMissing(row, locale))).length,
|
|
156
121
|
};
|
|
157
122
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
const
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
rows.push(row);
|
|
175
|
-
for (const locale of part.locales) {
|
|
176
|
-
const missing = part.localeMissing[locale] ?? 0;
|
|
177
|
-
expected[locale] = (expected[locale] ?? 0) + part.totalKeys;
|
|
178
|
-
existing[locale] = (existing[locale] ?? 0) + (part.totalKeys - missing);
|
|
179
|
-
localeMissing[locale] = (localeMissing[locale] ?? 0) + missing;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
const localeProgress = {};
|
|
183
|
-
for (const locale of Object.keys(expected)) {
|
|
184
|
-
const expectedKeys = expected[locale] ?? 0;
|
|
185
|
-
localeProgress[locale] =
|
|
186
|
-
expectedKeys > 0
|
|
187
|
-
? Math.round((existing[locale] / expectedKeys) * tree_1.PROGRESS_PRECISION_FACTOR) / tree_1.FULL_PROGRESS
|
|
188
|
-
: 0;
|
|
189
|
-
}
|
|
190
|
-
if (defaultLocale) {
|
|
191
|
-
localeProgress[defaultLocale] = tree_1.FULL_PROGRESS;
|
|
192
|
-
localeMissing[defaultLocale] = 0;
|
|
193
|
-
}
|
|
123
|
+
const STAMPED_FILES = {
|
|
124
|
+
default: registry_1.registryFiles,
|
|
125
|
+
modules: registry_1.registryFiles,
|
|
126
|
+
added: workspaces_1.workspaceFiles,
|
|
127
|
+
};
|
|
128
|
+
function computeFlat(workspace) {
|
|
129
|
+
const context = contextOf(workspace);
|
|
130
|
+
const rows = (0, tree_1.leafPaths)(keysOf(context)).map((key) => buildFlatRow(context, key));
|
|
131
|
+
return summarizeRows(context, rows);
|
|
132
|
+
}
|
|
133
|
+
function resolveFlat(workspace) {
|
|
134
|
+
const files = STAMPED_FILES[(0, workspaces_1.workspaceKind)(workspace)](workspace);
|
|
135
|
+
return (0, cache_1.memoize)(`flat:${workspace}`, (0, cache_1.filesStamp)(files), () => computeFlat(workspace));
|
|
136
|
+
}
|
|
137
|
+
function flatCounts(workspace) {
|
|
138
|
+
const flat = resolveFlat(workspace);
|
|
194
139
|
return {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
totalKeys,
|
|
140
|
+
localeProgress: flat.localeProgress,
|
|
141
|
+
localeMissing: flat.localeMissing,
|
|
142
|
+
totalKeys: flat.totalKeys,
|
|
143
|
+
baseMissing: flat.baseMissing,
|
|
144
|
+
incompleteKeys: flat.incompleteKeys,
|
|
201
145
|
};
|
|
202
146
|
}
|
|
147
|
+
function resolveRow(workspace, key) {
|
|
148
|
+
return resolveFlat(workspace).rows.find((row) => row.key === key);
|
|
149
|
+
}
|
|
203
150
|
//# sourceMappingURL=resolve.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/utils/resolve.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/utils/resolve.ts"],"names":[],"mappings":";;AA0KA,kCAKC;AAED,oCAEC;AAsDD,kCAKC;AAGD,gCASC;AAGD,gCAKC;AAlQD,mCAA8C;AAC9C,uCAAiE;AACjE,yCAA6C;AAC7C,mDAAkD;AAClD,yCAAyE;AACzE,qCAA2C;AAC3C,iCAQgB;AAChB,6CAOsB;AAsCtB,SAAS,MAAM,CAAC,OAAoB;IAClC,MAAM,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC;IACtE,OAAO,IAAA,gBAAS,EAAC,IAAI,IAAI,EAAE,EAAE,IAAA,gBAAS,EAAC,MAAM,CAAC,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,cAAc;IACrB,OAAO;QACL,aAAa,EAAE,IAAA,2BAAiB,GAAE;QAClC,OAAO,EAAE,IAAA,yBAAc,EAAC,KAAK,CAAC;QAC9B,QAAQ,EAAE,IAAA,uBAAY,EAAC,KAAK,CAAC;QAC7B,SAAS,EAAE,IAAA,uBAAY,EAAC,UAAU,C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AI,GAAG,IAAA,gBAAS,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAClD,YAAY,CAAC,OAAO,EAAE,GAAG,CAAC,CAC3B,CAAC;IACF,OAAO,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AACtC,CAAC;AAQD,SAAgB,WAAW,CAAC,SAAiB;IAC3C,MAAM,KAAK,GAAG,aAAa,CAAC,IAAA,0BAAa,EAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACjE,OAAO,IAAA,eAAO,EAAC,QAAQ,SAAS,EAAE,EAAE,IAAA,kBAAU,EAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAC1D,WAAW,CAAC,SAAS,CAAC,CACvB,CAAC;AACJ,CAAC;AAGD,SAAgB,UAAU,CAAC,SAAiB;IAC1C,MAAM,IAAI,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;IACpC,OAAO;QACL,cAAc,EAAE,IAAI,CAAC,cAAc;QACnC,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,cAAc,EAAE,IAAI,CAAC,cAAc;KACpC,CAAC;AACJ,CAAC;AAGD,SAAgB,UAAU,CACxB,SAAiB,EACjB,GAAW;IAEX,OAAO,WAAW,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { KeyStore } from "./keys";
|
|
2
|
+
import { type LocaleMessages } from "./tree";
|
|
3
|
+
import { type TranslationSources } from "./workspaces";
|
|
4
|
+
export declare function trackSources(store: KeyStore, workspace: string): KeyStore;
|
|
5
|
+
export declare function outdatedLocales(sources: TranslationSources | undefined, messages: LocaleMessages, base: string, path: string): string[];
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.trackSources = trackSources;
|
|
4
|
+
exports.outdatedLocales = outdatedLocales;
|
|
5
|
+
const node_crypto_1 = require("node:crypto");
|
|
6
|
+
const tree_1 = require("./tree");
|
|
7
|
+
const workspaces_1 = require("./workspaces");
|
|
8
|
+
const HASH_LENGTH = 12;
|
|
9
|
+
function fingerprint(text) {
|
|
10
|
+
return (0, node_crypto_1.createHash)("sha1").update(text).digest("hex").slice(0, HASH_LENGTH);
|
|
11
|
+
}
|
|
12
|
+
function baseText(messages, base, path) {
|
|
13
|
+
const value = (0, tree_1.getValueAtPath)(messages[base], path);
|
|
14
|
+
return typeof value === "string" && !(0, tree_1.isMissing)(value) ? value : undefined;
|
|
15
|
+
}
|
|
16
|
+
function recordTexts(sources, base, change) {
|
|
17
|
+
const source = baseText(change.messages, base, change.path);
|
|
18
|
+
for (const [locale, text] of Object.entries(change.texts ?? {})) {
|
|
19
|
+
if (locale === base)
|
|
20
|
+
continue;
|
|
21
|
+
sources[locale] ??= {};
|
|
22
|
+
if (text === null || source === undefined)
|
|
23
|
+
delete sources[locale][change.path];
|
|
24
|
+
else
|
|
25
|
+
sources[locale][change.path] = fingerprint(source);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function moveKey(sources, change) {
|
|
29
|
+
for (const records of Object.values(sources)) {
|
|
30
|
+
const hash = records[change.path];
|
|
31
|
+
delete records[change.path];
|
|
32
|
+
if (change.newPath !== undefined && hash !== undefined)
|
|
33
|
+
records[change.newPath] = hash;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function applyChange(manifest, change) {
|
|
37
|
+
const sources = manifest.sources ?? {};
|
|
38
|
+
if (change.texts)
|
|
39
|
+
recordTexts(sources, manifest.defaultLocale, change);
|
|
40
|
+
else
|
|
41
|
+
moveKey(sources, change);
|
|
42
|
+
manifest.sources = sources;
|
|
43
|
+
}
|
|
44
|
+
function trackSources(store, workspace) {
|
|
45
|
+
return {
|
|
46
|
+
...store,
|
|
47
|
+
track: (change) => (0, workspaces_1.updateManifest)(workspace, (manifest) => applyChange(manifest, change)),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function outdatedLocales(sources, messages, base, path) {
|
|
51
|
+
const source = baseText(messages, base, path);
|
|
52
|
+
if (!sources || source === undefined)
|
|
53
|
+
return [];
|
|
54
|
+
const current = fingerprint(source);
|
|
55
|
+
return Object.entries(sources)
|
|
56
|
+
.filter(([locale, records]) => {
|
|
57
|
+
const recorded = records[path];
|
|
58
|
+
return (recorded !== undefined &&
|
|
59
|
+
recorded !== current &&
|
|
60
|
+
!(0, tree_1.isMissing)((0, tree_1.getValueAtPath)(messages[locale], path)));
|
|
61
|
+
})
|
|
62
|
+
.map(([locale]) => locale);
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=review.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review.js","sourceRoot":"","sources":["../../src/utils/review.ts"],"names":[],"mappings":";;AAyDA,oCAMC;AAGD,0CAmBC;AArFD,6CAAyC;AAEzC,iCAAwE;AACxE,6CAIsB;AAEtB,MAAM,WAAW,GAAG,EAAE,CAAC;AAGvB,SAAS,WAAW,CAAC,IAAY;IAC/B,OAAO,IAAA,wBAAU,EAAC,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;AAC7E,CAAC;AAED,SAAS,QAAQ,CACf,QAAwB,EACxB,IAAY,EACZ,IAAY;IAEZ,MAAM,KAAK,GAAG,IAAA,qBAAc,EAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;IACnD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,IAAA,gBAA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PET_KINDS: readonly ["vue", "i18next", "fetch", "curl"];
|
|
2
|
+
export type SnippetKind = (typeof SNIPPET_KINDS)[number];
|
|
3
|
+
export interface Snippet {
|
|
4
|
+
code: string;
|
|
5
|
+
language: "javascript" | "shell" | "text";
|
|
6
|
+
}
|
|
7
|
+
export declare function workspaceSnippet(workspace: string, kind: SnippetKind, origin: string): Snippet;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SNIPPET_KINDS = void 0;
|
|
4
|
+
exports.workspaceSnippet = workspaceSnippet;
|
|
5
|
+
const catalog_1 = require("./catalog");
|
|
6
|
+
const constants_1 = require("./constants");
|
|
7
|
+
const locale_codes_1 = require("./locale-codes");
|
|
8
|
+
const public_url_1 = require("./public-url");
|
|
9
|
+
exports.SNIPPET_KINDS = ["vue", "i18next", "fetch", "curl"];
|
|
10
|
+
function supportedLanguages(locales) {
|
|
11
|
+
const languages = locales.map(locale_codes_1.languageOf);
|
|
12
|
+
return [...new Set([...locales, ...languages])].sort();
|
|
13
|
+
}
|
|
14
|
+
const FORMAT_NOTE = [
|
|
15
|
+
"// Messages use the vue-i18n format: {name} placeholders, plurals written",
|
|
16
|
+
"// \"one | many\" and a literal @ escaped as {'@'}.",
|
|
17
|
+
];
|
|
18
|
+
const SNIPPETS = {
|
|
19
|
+
vue: ({ url, base }) => ({
|
|
20
|
+
language: "javascript",
|
|
21
|
+
code: [
|
|
22
|
+
'import { createI18n } from "vue-i18n";',
|
|
23
|
+
"",
|
|
24
|
+
`const base = "${base}";`,
|
|
25
|
+
"const locale = navigator.language;",
|
|
26
|
+
"const load = async (code) => {",
|
|
27
|
+
` const response = await fetch(\`${(0, public_url_1.templateUrl)(url, "${code}")}\`);`,
|
|
28
|
+
" return response.ok ? response.json() : {};",
|
|
29
|
+
"};",
|
|
30
|
+
"// A file leaves out the keys it has no text for: fr-BE falls back to fr,",
|
|
31
|
+
"// then to the base, so all three are loaded.",
|
|
32
|
+
'const codes = [...new Set([base, locale.split("-")[0], locale])];',
|
|
33
|
+
"const messages = Object.fromEntries(",
|
|
34
|
+
" await Promise.all(codes.map(async (code) => [code, await load(code)])),",
|
|
35
|
+
");",
|
|
36
|
+
"",
|
|
37
|
+
"export const i18n = createI18n({",
|
|
38
|
+
" legacy: false,",
|
|
39
|
+
" locale,",
|
|
40
|
+
" fallbackLocale: base,",
|
|
41
|
+
" messages,",
|
|
42
|
+
"});",
|
|
43
|
+
].join("\n"),
|
|
44
|
+
}),
|
|
45
|
+
i18next: ({ url, base, locales }) => ({
|
|
46
|
+
language: "javascript",
|
|
47
|
+
code: [
|
|
48
|
+
'import i18next from "i18next";',
|
|
49
|
+
'import HttpBackend from "i18next-http-backend";',
|
|
50
|
+
"",
|
|
51
|
+
...FORMAT_NOTE,
|
|
52
|
+
"// i18next reads the placeholders with the interpolation below; it does not",
|
|
53
|
+
'// understand the "one | many" plurals.',
|
|
54
|
+
"await i18next.use(HttpBackend).init({",
|
|
55
|
+
" lng: navigator.language,",
|
|
56
|
+
` fallbackLng: "${base}",`,
|
|
57
|
+
` supportedLngs: ${JSON.stringify(supportedLanguages(locales))},`,
|
|
58
|
+
" nonExplicitSupportedLngs: true,",
|
|
59
|
+
' interpolation: { prefix: "{", suffix: "}" },',
|
|
60
|
+
" // The load path takes the same {…} placeholders.",
|
|
61
|
+
` backend: { loadPath: "${(0, public_url_1.templateUrl)(url, "{lng}")}" },`,
|
|
62
|
+
"});",
|
|
63
|
+
].join("\n"),
|
|
64
|
+
}),
|
|
65
|
+
fetch: ({ url, base }) => ({
|
|
66
|
+
language: "javascript",
|
|
67
|
+
code: [
|
|
68
|
+
'const isObject = (value) => typeof value === "object" && value !== null;',
|
|
69
|
+
"const merge = (target, source) => {",
|
|
70
|
+
" for (const [key, value] of Object.entries(source)) {",
|
|
71
|
+
" target[key] =",
|
|
72
|
+
" isObject(value) && isObject(target[key])",
|
|
73
|
+
" ? merge({ ...target[key] }, value)",
|
|
74
|
+
" : value;",
|
|
75
|
+
" }",
|
|
76
|
+
" return target;",
|
|
77
|
+
"};",
|
|
78
|
+
"",
|
|
79
|
+
`async function loadMessages(locale = navigator.language, base = "${base}") {`,
|
|
80
|
+
" // A file leaves out the keys it has no text for: the base, then the",
|
|
81
|
+
" // language (fr), then the locale (fr-BE) fill them in, in that order.",
|
|
82
|
+
' const codes = [...new Set([base, locale.split("-")[0], locale])];',
|
|
83
|
+
" const files = await Promise.all(",
|
|
84
|
+
" codes.map(async (code) => {",
|
|
85
|
+
` const response = await fetch(\`${(0, public_url_1.templateUrl)(url, "${code}")}\`);`,
|
|
86
|
+
" return response.ok ? response.json() : {};",
|
|
87
|
+
" }),",
|
|
88
|
+
" );",
|
|
89
|
+
" return files.reduce(merge, {});",
|
|
90
|
+
"}",
|
|
91
|
+
"",
|
|
92
|
+
"const messages = await loadMessages();",
|
|
93
|
+
].join("\n"),
|
|
94
|
+
}),
|
|
95
|
+
curl: ({ url, base }) => ({
|
|
96
|
+
language: "shell",
|
|
97
|
+
code: `curl ${(0, public_url_1.templateUrl)(url, base)}`,
|
|
98
|
+
}),
|
|
99
|
+
};
|
|
100
|
+
const LOCAL_SNIPPETS = {
|
|
101
|
+
default: [
|
|
102
|
+
"// Not served at a public URL: the dashboard loads these keys itself",
|
|
103
|
+
`// from ${constants_1.PROJECT_FILES}. In a component of this dashboard:`,
|
|
104
|
+
"const { t } = useI18n();",
|
|
105
|
+
't("app.title");',
|
|
106
|
+
],
|
|
107
|
+
modules: [
|
|
108
|
+
"// Not served at a public URL: each module ships these keys and the",
|
|
109
|
+
"// dashboard loads them itself. Override one in the project files",
|
|
110
|
+
`// (${constants_1.PROJECT_FILES}) to change it; in a component:`,
|
|
111
|
+
"const { t } = useI18n();",
|
|
112
|
+
't("dms.button.save");',
|
|
113
|
+
],
|
|
114
|
+
};
|
|
115
|
+
function workspaceSnippet(workspace, kind, origin) {
|
|
116
|
+
const summary = (0, catalog_1.findWorkspace)(workspace);
|
|
117
|
+
const url = (0, public_url_1.publicLocaleUrl)(origin, summary);
|
|
118
|
+
if (summary.kind !== "added" || !url) {
|
|
119
|
+
const local = LOCAL_SNIPPETS[summary.kind];
|
|
120
|
+
return { language: "javascript", code: local.join("\n") };
|
|
121
|
+
}
|
|
122
|
+
const build = SNIPPETS[kind];
|
|
123
|
+
return build({
|
|
124
|
+
url,
|
|
125
|
+
base: summary.defaultLocale || catalog_1.FALLBACK_LOCALE,
|
|
126
|
+
locales: summary.locales.map((locale) => locale.code),
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=snippets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snippets.js","sourceRoot":"","sources":["../../src/utils/snippets.ts"],"names":[],"mappings":";;;AAuIA,4CAiBC;AAxJD,uCAA2D;AAC3D,2CAA4C;AAC5C,iDAA4C;AAC5C,6CAA4D;AAG/C,QAAA,aAAa,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,CAAU,CAAC;AAmB1E,SAAS,kBAAkB,CAAC,OAAiB;IAC3C,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,yBAAU,CAAC,CAAC;IAC1C,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AACzD,CAAC;AAED,MAAM,WAAW,GAAG;IAClB,2EAA2E;IAC3E,qDAAqD;CACtD,CAAC;AAEF,MAAM,QAAQ,GAA0D;IACtE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QACvB,QAAQ,EAAE,YAAY;QACtB,IAAI,EAAE;YACJ,wCAAwC;YACxC,EAAE;YACF,iBAAiB,IAAI,IAAI;YACzB,oCAAoC;YACpC,gCAAgC;YAChC,oCAAoC,IAAA,wBAAW,EAAC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,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC;KACtD,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type FlatResult } from "./resolve";
|
|
2
|
+
import { type WorkspaceSummary } from "./workspaces";
|
|
3
|
+
export interface WorkspaceStats extends WorkspaceSummary {
|
|
4
|
+
baseLocale: string;
|
|
5
|
+
totalKeys: number;
|
|
6
|
+
translatedStrings: number;
|
|
7
|
+
missing: number;
|
|
8
|
+
coverage: number;
|
|
9
|
+
targets: number;
|
|
10
|
+
baseMissing: number;
|
|
11
|
+
incompleteKeys: number;
|
|
12
|
+
localeProgress: Record<string, number>;
|
|
13
|
+
localeMissing: Record<string, number>;
|
|
14
|
+
overrides: number;
|
|
15
|
+
publicUrl?: string;
|
|
16
|
+
}
|
|
17
|
+
export type PublicUrlOf = (workspace: WorkspaceSummary) => string | undefined;
|
|
18
|
+
export declare function countTranslated(flat: FlatResult): number;
|
|
19
|
+
export declare function targetLocales(flat: FlatResult): string[];
|
|
20
|
+
export declare function sumMissing(flat: FlatResult): number;
|
|
21
|
+
export declare function targetCoverage(flat: FlatResult): number | undefined;
|
|
22
|
+
export declare function summarizeWorkspaces(publicUrlOf?: PublicUrlOf): WorkspaceStats[];
|
|
23
|
+
export declare function countDefaultMissing(): number;
|