@antelopejs/dms-lang 0.0.6 → 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 +10 -5
- package/package.json +10 -8
- 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
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.countTranslated = countTranslated;
|
|
4
|
+
exports.targetLocales = targetLocales;
|
|
5
|
+
exports.sumMissing = sumMissing;
|
|
6
|
+
exports.targetCoverage = targetCoverage;
|
|
7
|
+
exports.summarizeWorkspaces = summarizeWorkspaces;
|
|
8
|
+
exports.countDefaultMissing = countDefaultMissing;
|
|
9
|
+
const catalog_1 = require("./catalog");
|
|
10
|
+
const resolve_1 = require("./resolve");
|
|
11
|
+
const coverage_1 = require("./coverage");
|
|
12
|
+
const workspaces_1 = require("./workspaces");
|
|
13
|
+
function countTranslated(flat) {
|
|
14
|
+
return flat.locales.reduce((total, locale) => total + flat.totalKeys - (flat.localeMissing[locale] ?? 0), 0);
|
|
15
|
+
}
|
|
16
|
+
function countOverrides(flat) {
|
|
17
|
+
return flat.rows.filter((row) => row.overridden === true).length;
|
|
18
|
+
}
|
|
19
|
+
function targetLocales(flat) {
|
|
20
|
+
return flat.locales.filter((locale) => locale !== flat.defaultLocale);
|
|
21
|
+
}
|
|
22
|
+
function sumMissing(flat) {
|
|
23
|
+
return targetLocales(flat).reduce((total, locale) => total + (flat.localeMissing[locale] ?? 0), 0);
|
|
24
|
+
}
|
|
25
|
+
function targetCoverage(flat) {
|
|
26
|
+
const expected = targetLocales(flat).length * flat.totalKeys;
|
|
27
|
+
if (expected === 0)
|
|
28
|
+
return undefined;
|
|
29
|
+
return (0, coverage_1.coveragePercent)(expected - sumMissing(flat), expected);
|
|
30
|
+
}
|
|
31
|
+
function describeWorkspace(workspace, publicUrlOf) {
|
|
32
|
+
const flat = (0, resolve_1.resolveFlat)(workspace.id);
|
|
33
|
+
const stats = {
|
|
34
|
+
...workspace,
|
|
35
|
+
baseLocale: flat.defaultLocale,
|
|
36
|
+
totalKeys: flat.totalKeys,
|
|
37
|
+
translatedStrings: countTranslated(flat),
|
|
38
|
+
missing: sumMissing(flat),
|
|
39
|
+
coverage: targetCoverage(flat) ?? coverage_1.FULL_COVERAGE,
|
|
40
|
+
targets: targetLocales(flat).length,
|
|
41
|
+
baseMissing: flat.baseMissing,
|
|
42
|
+
incompleteKeys: flat.incompleteKeys,
|
|
43
|
+
localeProgress: flat.localeProgress,
|
|
44
|
+
localeMissing: flat.localeMissing,
|
|
45
|
+
overrides: countOverrides(flat),
|
|
46
|
+
};
|
|
47
|
+
const publicUrl = publicUrlOf?.(workspace);
|
|
48
|
+
if (publicUrl !== undefined)
|
|
49
|
+
stats.publicUrl = publicUrl;
|
|
50
|
+
return stats;
|
|
51
|
+
}
|
|
52
|
+
function shareOverrides(stats) {
|
|
53
|
+
const overrides = stats.find((workspace) => workspace.id === workspaces_1.MODULES_WORKSPACE)?.overrides ??
|
|
54
|
+
0;
|
|
55
|
+
return stats.map((workspace) => workspace.id === workspaces_1.DEFAULT_WORKSPACE
|
|
56
|
+
? { ...workspace, overrides }
|
|
57
|
+
: workspace);
|
|
58
|
+
}
|
|
59
|
+
function summarizeWorkspaces(publicUrlOf) {
|
|
60
|
+
return shareOverrides((0, catalog_1.listAllWorkspaces)().map((workspace) => describeWorkspace(workspace, publicUrlOf)));
|
|
61
|
+
}
|
|
62
|
+
function countDefaultMissing() {
|
|
63
|
+
return sumMissing((0, resolve_1.resolveFlat)(workspaces_1.DEFAULT_WORKSPACE));
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=summary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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QAC7B,CAAC,CAAC,SAAS,CACd,CAAC;AACJ,CAAC;AAED,SAAgB,mBAAmB,CACjC,WAAyB;IAEzB,OAAO,cAAc,CACnB,IAAA,2BAAiB,GAAE,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CACpC,iBAAiB,CAAC,SAAS,EAAE,WAAW,CAAC,CAC1C,CACF,CAAC;AACJ,CAAC;AAED,SAAgB,mBAAmB;IACjC,OAAO,UAAU,CAAC,IAAA,qBAAW,EAAC,8BAAiB,CAAC,CAAC,CAAC;AACpD,CAAC"}
|
package/dist/utils/tree.d.ts
CHANGED
|
@@ -1,24 +1,9 @@
|
|
|
1
1
|
export type TranslationValue = string | number | boolean | null | undefined;
|
|
2
|
-
export interface TreeItem {
|
|
3
|
-
label: string;
|
|
4
|
-
value: string;
|
|
5
|
-
children?: TreeItem[];
|
|
6
|
-
defaultExpanded?: boolean;
|
|
7
|
-
trailingIcon?: string;
|
|
8
|
-
}
|
|
9
2
|
export interface LocaleMessages {
|
|
10
3
|
[locale: string]: Record<string, unknown>;
|
|
11
4
|
}
|
|
12
|
-
export interface TranslationData {
|
|
13
|
-
tree: TreeItem[];
|
|
14
|
-
localeProgress: Record<string, number>;
|
|
15
|
-
totalKeys: number;
|
|
16
|
-
}
|
|
17
|
-
export declare const PROGRESS_PRECISION_FACTOR = 10000;
|
|
18
|
-
export declare const FULL_PROGRESS = 100;
|
|
19
5
|
export declare function deepMerge(target: Record<string, unknown>, source: Record<string, unknown>): Record<string, unknown>;
|
|
20
6
|
export declare function getValueAtPath(obj: Record<string, unknown> | undefined, path: string): unknown;
|
|
21
7
|
export declare function isMissing(value: unknown): boolean;
|
|
22
|
-
export declare function
|
|
23
|
-
export declare function
|
|
24
|
-
export declare function collectLeafPaths(tree: TreeItem[]): string[];
|
|
8
|
+
export declare function unionKeys(messages: LocaleMessages): Record<string, unknown>;
|
|
9
|
+
export declare function leafPaths(keys: Record<string, unknown>, prefix?: string): string[];
|
package/dist/utils/tree.js
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FULL_PROGRESS = exports.PROGRESS_PRECISION_FACTOR = void 0;
|
|
4
3
|
exports.deepMerge = deepMerge;
|
|
5
4
|
exports.getValueAtPath = getValueAtPath;
|
|
6
5
|
exports.isMissing = isMissing;
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
9
|
-
|
|
10
|
-
const MISSING_ICON = "i-lucide-circle-alert";
|
|
11
|
-
exports.PROGRESS_PRECISION_FACTOR = 10000;
|
|
12
|
-
exports.FULL_PROGRESS = 100;
|
|
6
|
+
exports.unionKeys = unionKeys;
|
|
7
|
+
exports.leafPaths = leafPaths;
|
|
8
|
+
const json_1 = require("./json");
|
|
13
9
|
function deepMerge(target, source) {
|
|
14
10
|
const result = Object.assign(Object.create(null), target);
|
|
15
11
|
for (const key of Object.keys(source)) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
result[key] = deepMerge((
|
|
12
|
+
const value = source[key];
|
|
13
|
+
if ((0, json_1.isPlainObject)(value)) {
|
|
14
|
+
const current = result[key];
|
|
15
|
+
result[key] = deepMerge((0, json_1.isPlainObject)(current) ? current : {}, value);
|
|
20
16
|
}
|
|
21
17
|
else {
|
|
22
|
-
result[key] =
|
|
18
|
+
result[key] = value;
|
|
23
19
|
}
|
|
24
20
|
}
|
|
25
21
|
return result;
|
|
@@ -39,123 +35,22 @@ function getValueAtPath(obj, path) {
|
|
|
39
35
|
}
|
|
40
36
|
return current;
|
|
41
37
|
}
|
|
42
|
-
function isObject(value) {
|
|
43
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
44
|
-
}
|
|
45
38
|
function isMissing(value) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const result = analyzeNode(value, fullPath, localeMessages);
|
|
55
|
-
keyCount += result.keyCount;
|
|
56
|
-
hasMissing = hasMissing || result.hasMissing;
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
keyCount += 1;
|
|
60
|
-
if (!hasMissing) {
|
|
61
|
-
hasMissing = Object.values(localeMessages).some((messages) => {
|
|
62
|
-
return isMissing(getValueAtPath(messages, fullPath));
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return { keyCount, hasMissing };
|
|
68
|
-
}
|
|
69
|
-
function buildTree(obj, localeMessages, prefix = "") {
|
|
70
|
-
return Object.entries(obj).map(([key, value]) => {
|
|
71
|
-
const fullPath = prefix ? `${prefix}.${key}` : key;
|
|
72
|
-
if (isObject(value)) {
|
|
73
|
-
const { hasMissing } = analyzeNode(value, fullPath, localeMessages);
|
|
74
|
-
return {
|
|
75
|
-
label: key,
|
|
76
|
-
value: fullPath,
|
|
77
|
-
children: buildTree(value, localeMessages, fullPath),
|
|
78
|
-
defaultExpanded: false,
|
|
79
|
-
trailingIcon: hasMissing ? MISSING_ICON : undefined,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
const hasMissing = Object.values(localeMessages).some((messages) => {
|
|
83
|
-
return isMissing(getValueAtPath(messages, fullPath));
|
|
84
|
-
});
|
|
85
|
-
return {
|
|
86
|
-
label: key,
|
|
87
|
-
value: fullPath,
|
|
88
|
-
trailingIcon: hasMissing ? MISSING_ICON : undefined,
|
|
89
|
-
};
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
function countExisting(localeObj, refObj) {
|
|
93
|
-
let count = 0;
|
|
94
|
-
for (const [key, refValue] of Object.entries(refObj)) {
|
|
95
|
-
const localeValue = localeObj?.[key];
|
|
96
|
-
if (isObject(refValue)) {
|
|
97
|
-
count += countExisting(localeValue, refValue);
|
|
98
|
-
}
|
|
99
|
-
else if (!isMissing(localeValue)) {
|
|
100
|
-
count += 1;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return count;
|
|
104
|
-
}
|
|
105
|
-
function computeLocaleProgress(structureMessages, presenceMessages, defaultMessages, defaultLocaleCode, totalKeys) {
|
|
106
|
-
const localeCodes = new Set([
|
|
107
|
-
...Object.keys(structureMessages),
|
|
108
|
-
...Object.keys(presenceMessages),
|
|
109
|
-
]);
|
|
110
|
-
const localeProgress = {};
|
|
111
|
-
localeCodes.forEach((localeCode) => {
|
|
112
|
-
if (localeCode === defaultLocaleCode) {
|
|
113
|
-
localeProgress[localeCode] = exports.FULL_PROGRESS;
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
const existing = countExisting(presenceMessages[localeCode], defaultMessages);
|
|
117
|
-
localeProgress[localeCode] =
|
|
118
|
-
totalKeys > 0
|
|
119
|
-
? Math.round((existing / totalKeys) * exports.PROGRESS_PRECISION_FACTOR) /
|
|
120
|
-
exports.FULL_PROGRESS
|
|
121
|
-
: 0;
|
|
122
|
-
});
|
|
123
|
-
return localeProgress;
|
|
124
|
-
}
|
|
125
|
-
function buildTranslationData(structureMessages, defaultLocaleCode, presenceMessages = structureMessages) {
|
|
126
|
-
const defaultMessages = structureMessages[defaultLocaleCode];
|
|
127
|
-
if (!defaultMessages || Object.keys(defaultMessages).length === 0) {
|
|
128
|
-
return {
|
|
129
|
-
tree: [],
|
|
130
|
-
localeProgress: {},
|
|
131
|
-
totalKeys: 0,
|
|
132
|
-
};
|
|
39
|
+
if (value === undefined || value === null)
|
|
40
|
+
return true;
|
|
41
|
+
return typeof value === "string" && value.trim() === "";
|
|
42
|
+
}
|
|
43
|
+
function unionKeys(messages) {
|
|
44
|
+
let union = {};
|
|
45
|
+
for (const localeMessages of Object.values(messages)) {
|
|
46
|
+
union = deepMerge(union, localeMessages);
|
|
133
47
|
}
|
|
134
|
-
|
|
135
|
-
const { keyCount: totalKeys } = analyzeNode(defaultMessages, "", presenceMessages);
|
|
136
|
-
const localeProgress = computeLocaleProgress(structureMessages, presenceMessages, defaultMessages, defaultLocaleCode, totalKeys);
|
|
137
|
-
return { tree, localeProgress, totalKeys };
|
|
48
|
+
return union;
|
|
138
49
|
}
|
|
139
|
-
function
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
translations[localeCode] = isMissing(value)
|
|
144
|
-
? undefined
|
|
145
|
-
: value;
|
|
50
|
+
function leafPaths(keys, prefix = "") {
|
|
51
|
+
return Object.entries(keys).flatMap(([key, value]) => {
|
|
52
|
+
const path = prefix ? `${prefix}.${key}` : key;
|
|
53
|
+
return (0, json_1.isPlainObject)(value) ? leafPaths(value, path) : [path];
|
|
146
54
|
});
|
|
147
|
-
return translations;
|
|
148
|
-
}
|
|
149
|
-
function collectLeafPaths(tree) {
|
|
150
|
-
const paths = [];
|
|
151
|
-
for (const node of tree) {
|
|
152
|
-
if (node.children && node.children.length > 0) {
|
|
153
|
-
paths.push(...collectLeafPaths(node.children));
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
paths.push(node.value);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
return paths;
|
|
160
55
|
}
|
|
161
56
|
//# sourceMappingURL=tree.js.map
|
package/dist/utils/tree.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../../src/utils/tree.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../../src/utils/tree.ts"],"names":[],"mappings":";;AAQA,8BAoBC;AAED,wCAkBC;AAGD,8BAGC;AAGD,8BAMC;AAGD,8BAQC;AA1ED,iCAAuC;AAQvC,SAAgB,SAAS,CACvB,MAA+B,EAC/B,MAA+B;IAE/B,MAAM,MAAM,GAA4B,MAAM,CAAC,MAAM,CACnD,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EACnB,MAAM,CACP,CAAC;IAEF,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,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ChD,IAAI,KAAK,GAA4B,EAAE,CAAC;IACxC,KAAK,MAAM,cAAc,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QACrD,KAAK,GAAG,SAAS,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAGD,SAAgB,SAAS,CACvB,IAA6B,EAC7B,MAAM,GAAG,EAAE;IAEX,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QACnD,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QAC/C,OAAO,IAAA,oBAAa,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,19 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { KeyStore } from "./keys";
|
|
2
|
+
import type { LocaleMessages } from "./tree";
|
|
2
3
|
export interface WorkspaceLocale {
|
|
3
4
|
code: string;
|
|
4
5
|
name?: string;
|
|
5
6
|
flag?: string;
|
|
6
7
|
}
|
|
7
|
-
export
|
|
8
|
+
export declare const WORKSPACE_TYPES: readonly ["dms", "website", "mobile", "other"];
|
|
9
|
+
type WorkspaceType = (typeof WORKSPACE_TYPES)[number];
|
|
10
|
+
export interface WorkspaceDetails {
|
|
11
|
+
description?: string;
|
|
12
|
+
type?: WorkspaceType;
|
|
13
|
+
}
|
|
14
|
+
export type TranslationSources = Record<string, Record<string, string>>;
|
|
15
|
+
export interface WorkspaceManifest extends WorkspaceDetails {
|
|
8
16
|
defaultLocale: string;
|
|
9
17
|
locales: WorkspaceLocale[];
|
|
18
|
+
sources?: TranslationSources;
|
|
10
19
|
}
|
|
11
20
|
export declare const DEFAULT_WORKSPACE = "default";
|
|
12
21
|
export declare const MODULES_WORKSPACE = "modules";
|
|
13
|
-
export declare const ALL_WORKSPACE = "all";
|
|
14
22
|
export type WorkspaceKind = "default" | "modules" | "added";
|
|
15
23
|
export declare function workspaceKind(workspace: string): WorkspaceKind;
|
|
16
|
-
export interface WorkspaceSummary {
|
|
24
|
+
export interface WorkspaceSummary extends WorkspaceDetails {
|
|
17
25
|
id: string;
|
|
18
26
|
kind: WorkspaceKind;
|
|
19
27
|
editable: boolean;
|
|
@@ -21,18 +29,40 @@ export interface WorkspaceSummary {
|
|
|
21
29
|
locales: WorkspaceLocale[];
|
|
22
30
|
}
|
|
23
31
|
export declare function assertEditable(): void;
|
|
24
|
-
export declare function
|
|
25
|
-
export declare function
|
|
32
|
+
export declare function normalizeWorkspaceId(id?: string): string;
|
|
33
|
+
export declare function hasWorkspace(id: string): boolean;
|
|
34
|
+
export declare function updateManifest(id: string, change: (manifest: WorkspaceManifest) => void): WorkspaceManifest;
|
|
26
35
|
export declare function listWorkspaces(): WorkspaceSummary[];
|
|
27
|
-
export declare function
|
|
36
|
+
export declare function getWorkspaceSummary(id: string): WorkspaceSummary;
|
|
28
37
|
export declare function getWorkspaceManifest(id: string): WorkspaceManifest;
|
|
29
|
-
export declare function
|
|
30
|
-
export declare function
|
|
31
|
-
export
|
|
38
|
+
export declare function loadWorkspaceMessages(id: string): LocaleMessages;
|
|
39
|
+
export declare function workspaceFiles(id: string): string[];
|
|
40
|
+
export interface ServedLocale {
|
|
41
|
+
code: string;
|
|
42
|
+
messages: Record<string, unknown>;
|
|
43
|
+
}
|
|
44
|
+
export declare function readWorkspaceLocale(id: string, code: string): ServedLocale | null;
|
|
45
|
+
export interface DetailsInput {
|
|
46
|
+
description?: string | null;
|
|
47
|
+
type?: WorkspaceType | "" | null;
|
|
48
|
+
}
|
|
49
|
+
export declare function validateLocaleEntry(locale: WorkspaceLocale): WorkspaceLocale;
|
|
50
|
+
export interface WorkspaceSeed extends DetailsInput {
|
|
51
|
+
defaultLocale: string;
|
|
52
|
+
locales: WorkspaceLocale[];
|
|
53
|
+
messages: LocaleMessages;
|
|
54
|
+
}
|
|
55
|
+
export declare function writeNewWorkspace(rawId: string, seed: WorkspaceSeed): string;
|
|
56
|
+
export declare function createWorkspace(id: string, locale: WorkspaceLocale, details?: DetailsInput): string;
|
|
57
|
+
export declare function updateWorkspaceDetails(id: string, details: DetailsInput): WorkspaceSummary;
|
|
58
|
+
export declare function renameWorkspace(id: string, newId: string): string;
|
|
32
59
|
export declare function deleteWorkspace(id: string): void;
|
|
33
|
-
export
|
|
60
|
+
export interface AddedLocale {
|
|
61
|
+
code: string;
|
|
62
|
+
sameLanguage: string[];
|
|
63
|
+
}
|
|
64
|
+
export declare function addLocale(id: string, locale: WorkspaceLocale): AddedLocale;
|
|
34
65
|
export declare function removeLocale(id: string, code: string): void;
|
|
35
|
-
export declare function setWorkspaceDefaultLocale(id: string, code: string):
|
|
36
|
-
export declare function
|
|
37
|
-
export
|
|
38
|
-
export declare function deleteKey(id: string, path: string): void;
|
|
66
|
+
export declare function setWorkspaceDefaultLocale(id: string, code: string): string;
|
|
67
|
+
export declare function workspaceKeyStore(id: string): KeyStore;
|
|
68
|
+
export {};
|