@antelopejs/dms-lang 0.0.7 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +11 -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
|
@@ -1,498 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { useDmsRoute } from '#dms/frontend-module'
|
|
3
|
-
import TranslationMatrix from '../../build/components/pages/lang/TranslationMatrix.vue'
|
|
4
|
-
import {
|
|
5
|
-
type FlatTranslationRow,
|
|
6
|
-
isLocaleValueMissing,
|
|
7
|
-
} from '../../composables/translation/useTranslationProgress'
|
|
8
|
-
|
|
9
|
-
interface LocaleColumn {
|
|
10
|
-
code: string
|
|
11
|
-
name: string
|
|
12
|
-
flag: string
|
|
13
|
-
isDefault: boolean
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface SavePayload {
|
|
17
|
-
key: string
|
|
18
|
-
locale: string
|
|
19
|
-
value: string
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
type TranslationFilter = 'all' | 'missing' | 'complete'
|
|
23
|
-
|
|
24
|
-
const FILTER_PREDICATES: Record<
|
|
25
|
-
TranslationFilter,
|
|
26
|
-
(missing: boolean) => boolean
|
|
27
|
-
> = {
|
|
28
|
-
all: () => true,
|
|
29
|
-
missing: (missing) => missing,
|
|
30
|
-
complete: (missing) => !missing,
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const route = useDmsRoute()
|
|
34
|
-
const { t } = useI18n()
|
|
35
|
-
const toast = useToast()
|
|
36
|
-
const { confirm } = useConfirm()
|
|
37
|
-
const { localeMetaOf } = useLocaleMeta()
|
|
38
|
-
const { tryMutate } = useMutationToast()
|
|
39
|
-
|
|
40
|
-
const {
|
|
41
|
-
editable: devEditable,
|
|
42
|
-
selectedWorkspace,
|
|
43
|
-
upsertKey,
|
|
44
|
-
renameKey,
|
|
45
|
-
deleteKey,
|
|
46
|
-
} = useI18nWorkspaces()
|
|
47
|
-
|
|
48
|
-
const { isDefault, isModules, isEditable, canManage } = useWorkspaceContext()
|
|
49
|
-
|
|
50
|
-
const initialFilter =
|
|
51
|
-
route.query.filter === 'missing' || route.query.filter === 'complete'
|
|
52
|
-
? route.query.filter
|
|
53
|
-
: 'all'
|
|
54
|
-
const initialLocale =
|
|
55
|
-
typeof route.query.locale === 'string' ? route.query.locale : ''
|
|
56
|
-
|
|
57
|
-
const filter = ref<TranslationFilter>(initialFilter)
|
|
58
|
-
const search = ref('')
|
|
59
|
-
const { flat, isLoading, loadFlat, reload, removeLanguage } = useWorkspaceFlat()
|
|
60
|
-
|
|
61
|
-
const canManageKeys = computed(() => isEditable.value && !isModules.value)
|
|
62
|
-
const canEditValues = computed(() => isEditable.value && !isModules.value)
|
|
63
|
-
const showOverride = computed(() => isModules.value && devEditable.value)
|
|
64
|
-
|
|
65
|
-
const allLocaleColumns = computed<LocaleColumn[]>(() => {
|
|
66
|
-
const fallback = flat.value.defaultLocale
|
|
67
|
-
return [...flat.value.locales]
|
|
68
|
-
.sort((a, b) => (a === fallback ? -1 : b === fallback ? 1 : 0))
|
|
69
|
-
.map((code) => ({
|
|
70
|
-
code,
|
|
71
|
-
...localeMetaOf(code),
|
|
72
|
-
isDefault: code === fallback,
|
|
73
|
-
}))
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
const visibleOrder = ref<string[]>([])
|
|
77
|
-
let localeFocusPending = Boolean(initialLocale)
|
|
78
|
-
|
|
79
|
-
function focusedOrder(codes: string[]): string[] | null {
|
|
80
|
-
if (!codes.includes(initialLocale)) return null
|
|
81
|
-
const fallback = flat.value.defaultLocale
|
|
82
|
-
if (initialLocale === fallback) return [initialLocale]
|
|
83
|
-
return codes.includes(fallback) ? [fallback, initialLocale] : [initialLocale]
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
watch(
|
|
87
|
-
() => allLocaleColumns.value.map((column) => column.code).join(','),
|
|
88
|
-
() => {
|
|
89
|
-
const codes = allLocaleColumns.value.map((column) => column.code)
|
|
90
|
-
if (codes.length > 0 && localeFocusPending) {
|
|
91
|
-
localeFocusPending = false
|
|
92
|
-
const focused = focusedOrder(codes)
|
|
93
|
-
if (focused) {
|
|
94
|
-
visibleOrder.value = focused
|
|
95
|
-
return
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
visibleOrder.value = codes
|
|
99
|
-
},
|
|
100
|
-
{ immediate: true },
|
|
101
|
-
)
|
|
102
|
-
|
|
103
|
-
const displayColumns = computed<LocaleColumn[]>(() => {
|
|
104
|
-
const byCode = new Map(
|
|
105
|
-
allLocaleColumns.value.map((column) => [column.code, column]),
|
|
106
|
-
)
|
|
107
|
-
return visibleOrder.value
|
|
108
|
-
.map((code) => byCode.get(code))
|
|
109
|
-
.filter((column): column is LocaleColumn => Boolean(column))
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
function isColumnShown(code: string): boolean {
|
|
113
|
-
return visibleOrder.value.includes(code)
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function toggleColumn(code: string) {
|
|
117
|
-
visibleOrder.value = visibleOrder.value.includes(code)
|
|
118
|
-
? visibleOrder.value.filter((current) => current !== code)
|
|
119
|
-
: [...visibleOrder.value, code]
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function moveColumn(code: string, direction: -1 | 1) {
|
|
123
|
-
const index = visibleOrder.value.indexOf(code)
|
|
124
|
-
const target = index + direction
|
|
125
|
-
if (index < 0 || target < 0 || target >= visibleOrder.value.length) return
|
|
126
|
-
const next = [...visibleOrder.value]
|
|
127
|
-
;[next[index], next[target]] = [next[target], next[index]]
|
|
128
|
-
visibleOrder.value = next
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const columnManagerRows = computed(() => {
|
|
132
|
-
const shown = displayColumns.value.map((column) => ({
|
|
133
|
-
...column,
|
|
134
|
-
shown: true,
|
|
135
|
-
}))
|
|
136
|
-
const hidden = allLocaleColumns.value
|
|
137
|
-
.filter((column) => !isColumnShown(column.code))
|
|
138
|
-
.map((column) => ({ ...column, shown: false }))
|
|
139
|
-
return [...shown, ...hidden]
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
function rowMissing(row: FlatTranslationRow): boolean {
|
|
143
|
-
return displayColumns.value
|
|
144
|
-
.filter((column) => !column.isDefault)
|
|
145
|
-
.some((column) => isLocaleValueMissing(row.values[column.code]))
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
const counts = computed(() => {
|
|
149
|
-
const missing = flat.value.rows.filter(rowMissing).length
|
|
150
|
-
return {
|
|
151
|
-
all: flat.value.rows.length,
|
|
152
|
-
missing,
|
|
153
|
-
complete: flat.value.rows.length - missing,
|
|
154
|
-
}
|
|
155
|
-
})
|
|
156
|
-
|
|
157
|
-
const filterItems = computed(() => [
|
|
158
|
-
{
|
|
159
|
-
label: `${t('dms_lang.editor.filter_all')} ${counts.value.all}`,
|
|
160
|
-
value: 'all',
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
label: `${t('dms_lang.editor.filter_missing')} ${counts.value.missing}`,
|
|
164
|
-
value: 'missing',
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
label: `${t('dms_lang.editor.filter_complete')} ${counts.value.complete}`,
|
|
168
|
-
value: 'complete',
|
|
169
|
-
},
|
|
170
|
-
])
|
|
171
|
-
|
|
172
|
-
const filteredRows = computed(() => {
|
|
173
|
-
const needle = search.value.trim().toLowerCase()
|
|
174
|
-
const matchesFilter = FILTER_PREDICATES[filter.value]
|
|
175
|
-
return flat.value.rows.filter((row) => {
|
|
176
|
-
const passFilter = matchesFilter(rowMissing(row))
|
|
177
|
-
const passSearch = !needle || row.key.toLowerCase().includes(needle)
|
|
178
|
-
return passFilter && passSearch
|
|
179
|
-
})
|
|
180
|
-
})
|
|
181
|
-
|
|
182
|
-
function toMatrixValues(
|
|
183
|
-
source: Record<string, unknown>,
|
|
184
|
-
): Record<string, string | undefined> {
|
|
185
|
-
const result: Record<string, string | undefined> = {}
|
|
186
|
-
for (const code of flat.value.locales) {
|
|
187
|
-
const value = source[code]
|
|
188
|
-
result[code] = value == null ? undefined : String(value)
|
|
189
|
-
}
|
|
190
|
-
return result
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
const matrixRows = computed(() =>
|
|
194
|
-
filteredRows.value.map((row) => ({
|
|
195
|
-
key: row.key,
|
|
196
|
-
values: toMatrixValues(row.values),
|
|
197
|
-
inherited: row.inherited ? toMatrixValues(row.inherited) : undefined,
|
|
198
|
-
})),
|
|
199
|
-
)
|
|
200
|
-
|
|
201
|
-
async function onSave(payload: SavePayload) {
|
|
202
|
-
const ok = await tryMutate(() =>
|
|
203
|
-
upsertKey(
|
|
204
|
-
selectedWorkspace.value,
|
|
205
|
-
payload.key,
|
|
206
|
-
{ [payload.locale]: payload.value },
|
|
207
|
-
flat.value.defaultLocale,
|
|
208
|
-
),
|
|
209
|
-
)
|
|
210
|
-
if (!ok) return
|
|
211
|
-
const row = flat.value.rows.find((item) => item.key === payload.key)
|
|
212
|
-
if (row)
|
|
213
|
-
row.values[payload.locale] =
|
|
214
|
-
payload.value === '' ? undefined : payload.value
|
|
215
|
-
toast.add({ title: t('dms_lang.translation.ws_saved'), color: 'success' })
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
function overrideKey(key: string) {
|
|
219
|
-
selectedWorkspace.value = DEFAULT_WORKSPACE
|
|
220
|
-
filter.value = 'all'
|
|
221
|
-
search.value = key
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
const langAddOpen = ref(false)
|
|
225
|
-
|
|
226
|
-
const keyAddOpen = ref(false)
|
|
227
|
-
const keyAddForm = ref({ path: '' })
|
|
228
|
-
const keyRenameOpen = ref(false)
|
|
229
|
-
const keyRenameForm = ref({ path: '', newPath: '' })
|
|
230
|
-
|
|
231
|
-
function openAddKey() {
|
|
232
|
-
keyAddForm.value = { path: '' }
|
|
233
|
-
keyAddOpen.value = true
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
async function submitAddKey() {
|
|
237
|
-
const path = keyAddForm.value.path.trim()
|
|
238
|
-
if (!path) return
|
|
239
|
-
const seed = isDefault.value ? { [flat.value.defaultLocale]: '' } : {}
|
|
240
|
-
const ok = await tryMutate(() =>
|
|
241
|
-
upsertKey(selectedWorkspace.value, path, seed, flat.value.defaultLocale),
|
|
242
|
-
)
|
|
243
|
-
if (!ok) return
|
|
244
|
-
keyAddOpen.value = false
|
|
245
|
-
await loadFlat()
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
function openRenameKey(key: string) {
|
|
249
|
-
keyRenameForm.value = { path: key, newPath: key }
|
|
250
|
-
keyRenameOpen.value = true
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
async function submitRenameKey() {
|
|
254
|
-
const { path, newPath } = keyRenameForm.value
|
|
255
|
-
const ok = await tryMutate(() =>
|
|
256
|
-
renameKey(selectedWorkspace.value, path, newPath),
|
|
257
|
-
)
|
|
258
|
-
if (!ok) return
|
|
259
|
-
keyRenameOpen.value = false
|
|
260
|
-
await loadFlat()
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
async function requestDeleteKey(key: string) {
|
|
264
|
-
const workspace = selectedWorkspace.value
|
|
265
|
-
const confirmed = await confirm({
|
|
266
|
-
title: t('dms_lang.translation.ws_delete_key_title'),
|
|
267
|
-
description: t('dms_lang.translation.ws_delete_key_confirm', { path: key }),
|
|
268
|
-
confirmLabel: t('dms_lang.translation.ws_delete'),
|
|
269
|
-
confirmColor: 'error',
|
|
270
|
-
})
|
|
271
|
-
if (!confirmed) return
|
|
272
|
-
const ok = await tryMutate(() => deleteKey(workspace, key))
|
|
273
|
-
if (!ok) return
|
|
274
|
-
await loadFlat()
|
|
275
|
-
}
|
|
276
|
-
</script>
|
|
277
|
-
|
|
278
|
-
<template>
|
|
279
|
-
<div class="space-y-6">
|
|
280
|
-
<div class="flex flex-wrap items-center gap-3">
|
|
281
|
-
<DmsLangWorkspaceStatus />
|
|
282
|
-
|
|
283
|
-
<div class="flex-1" />
|
|
284
|
-
|
|
285
|
-
<UButton
|
|
286
|
-
v-if="canManage"
|
|
287
|
-
icon="i-lucide-languages"
|
|
288
|
-
color="neutral"
|
|
289
|
-
variant="subtle"
|
|
290
|
-
:label="$t('dms_lang.translation.ws_add_language')"
|
|
291
|
-
@click="langAddOpen = true"
|
|
292
|
-
/>
|
|
293
|
-
</div>
|
|
294
|
-
|
|
295
|
-
<DmsLangWorkspaceEndpoint />
|
|
296
|
-
|
|
297
|
-
<div class="flex flex-wrap items-center gap-3">
|
|
298
|
-
<DmsSegmented
|
|
299
|
-
v-model="filter"
|
|
300
|
-
:items="filterItems"
|
|
301
|
-
:aria-label="$t('dms_lang.editor.filter_all')"
|
|
302
|
-
/>
|
|
303
|
-
<UInput
|
|
304
|
-
v-model="search"
|
|
305
|
-
icon="i-lucide-search"
|
|
306
|
-
:placeholder="$t('dms_lang.editor.search_placeholder')"
|
|
307
|
-
class="w-64"
|
|
308
|
-
/>
|
|
309
|
-
<div class="flex-1" />
|
|
310
|
-
|
|
311
|
-
<UPopover>
|
|
312
|
-
<UButton
|
|
313
|
-
icon="i-lucide-columns-3"
|
|
314
|
-
color="neutral"
|
|
315
|
-
variant="subtle"
|
|
316
|
-
size="sm"
|
|
317
|
-
:label="$t('dms_lang.editor.columns')"
|
|
318
|
-
/>
|
|
319
|
-
<template #content>
|
|
320
|
-
<div class="w-72 space-y-0.5 p-2">
|
|
321
|
-
<div
|
|
322
|
-
v-for="column in columnManagerRows"
|
|
323
|
-
:key="column.code"
|
|
324
|
-
class="hover:bg-elevated/50 flex items-center gap-2 rounded-md px-2 py-1.5"
|
|
325
|
-
>
|
|
326
|
-
<UCheckbox
|
|
327
|
-
:model-value="column.shown"
|
|
328
|
-
@update:model-value="toggleColumn(column.code)"
|
|
329
|
-
/>
|
|
330
|
-
<UIcon
|
|
331
|
-
:name="
|
|
332
|
-
column.flag ? `flagpack:${column.flag}` : 'i-lucide-globe'
|
|
333
|
-
"
|
|
334
|
-
class="size-4 shrink-0"
|
|
335
|
-
/>
|
|
336
|
-
<span class="min-w-0 flex-1 truncate text-sm">
|
|
337
|
-
{{ column.name }}
|
|
338
|
-
</span>
|
|
339
|
-
<UBadge
|
|
340
|
-
v-if="column.isDefault"
|
|
341
|
-
color="neutral"
|
|
342
|
-
variant="subtle"
|
|
343
|
-
size="sm"
|
|
344
|
-
>
|
|
345
|
-
{{ $t('dms_lang.editor.base') }}
|
|
346
|
-
</UBadge>
|
|
347
|
-
<template v-if="column.shown">
|
|
348
|
-
<UButton
|
|
349
|
-
icon="i-lucide-chevron-up"
|
|
350
|
-
color="neutral"
|
|
351
|
-
variant="ghost"
|
|
352
|
-
size="xs"
|
|
353
|
-
:aria-label="$t('dms_lang.editor.move_up')"
|
|
354
|
-
@click="moveColumn(column.code, -1)"
|
|
355
|
-
/>
|
|
356
|
-
<UButton
|
|
357
|
-
icon="i-lucide-chevron-down"
|
|
358
|
-
color="neutral"
|
|
359
|
-
variant="ghost"
|
|
360
|
-
size="xs"
|
|
361
|
-
:aria-label="$t('dms_lang.editor.move_down')"
|
|
362
|
-
@click="moveColumn(column.code, 1)"
|
|
363
|
-
/>
|
|
364
|
-
</template>
|
|
365
|
-
<UButton
|
|
366
|
-
v-if="canManage && !column.isDefault"
|
|
367
|
-
icon="i-lucide-trash-2"
|
|
368
|
-
color="error"
|
|
369
|
-
variant="ghost"
|
|
370
|
-
size="xs"
|
|
371
|
-
:aria-label="$t('dms_lang.translation.ws_delete')"
|
|
372
|
-
@click="removeLanguage(column.code)"
|
|
373
|
-
/>
|
|
374
|
-
</div>
|
|
375
|
-
|
|
376
|
-
<template v-if="canManage">
|
|
377
|
-
<USeparator class="my-1.5" />
|
|
378
|
-
<UButton
|
|
379
|
-
icon="i-lucide-plus"
|
|
380
|
-
color="neutral"
|
|
381
|
-
variant="ghost"
|
|
382
|
-
size="sm"
|
|
383
|
-
block
|
|
384
|
-
:label="$t('dms_lang.translation.ws_add_language')"
|
|
385
|
-
@click="langAddOpen = true"
|
|
386
|
-
/>
|
|
387
|
-
</template>
|
|
388
|
-
</div>
|
|
389
|
-
</template>
|
|
390
|
-
</UPopover>
|
|
391
|
-
|
|
392
|
-
<UButton
|
|
393
|
-
v-if="canManageKeys"
|
|
394
|
-
icon="i-lucide-plus"
|
|
395
|
-
color="neutral"
|
|
396
|
-
variant="subtle"
|
|
397
|
-
size="sm"
|
|
398
|
-
:label="$t('dms_lang.translation.ws_add_key')"
|
|
399
|
-
@click="openAddKey"
|
|
400
|
-
/>
|
|
401
|
-
</div>
|
|
402
|
-
|
|
403
|
-
<div class="relative">
|
|
404
|
-
<div
|
|
405
|
-
v-if="isLoading"
|
|
406
|
-
class="bg-default/50 absolute inset-0 z-30 flex items-center justify-center rounded-xl"
|
|
407
|
-
>
|
|
408
|
-
<div class="text-center">
|
|
409
|
-
<UIcon
|
|
410
|
-
name="i-lucide-loader-circle"
|
|
411
|
-
class="text-muted mb-2 size-8 animate-spin"
|
|
412
|
-
/>
|
|
413
|
-
<p class="text-muted text-xs">
|
|
414
|
-
{{ $t('dms_lang.translation.loading_translations') }}
|
|
415
|
-
</p>
|
|
416
|
-
</div>
|
|
417
|
-
</div>
|
|
418
|
-
|
|
419
|
-
<DmsCard :padded="false">
|
|
420
|
-
<TranslationMatrix
|
|
421
|
-
:rows="matrixRows"
|
|
422
|
-
:columns="displayColumns"
|
|
423
|
-
:editable="canEditValues"
|
|
424
|
-
:show-inherited="isDefault"
|
|
425
|
-
:overridable="showOverride"
|
|
426
|
-
:manage-keys="canManageKeys"
|
|
427
|
-
:reset-key="`${selectedWorkspace}|${filter}|${search}`"
|
|
428
|
-
@save="onSave"
|
|
429
|
-
@rename="openRenameKey"
|
|
430
|
-
@remove="requestDeleteKey"
|
|
431
|
-
@override="overrideKey"
|
|
432
|
-
/>
|
|
433
|
-
</DmsCard>
|
|
434
|
-
</div>
|
|
435
|
-
|
|
436
|
-
<DmsLangLanguageAddModal v-model:open="langAddOpen" @added="reload" />
|
|
437
|
-
|
|
438
|
-
<UModal
|
|
439
|
-
v-model:open="keyAddOpen"
|
|
440
|
-
:title="$t('dms_lang.translation.ws_add_key')"
|
|
441
|
-
>
|
|
442
|
-
<template #body>
|
|
443
|
-
<UFormField
|
|
444
|
-
:label="$t('dms_lang.translation.ws_key_path')"
|
|
445
|
-
:help="$t('dms_lang.translation.ws_key_path_help')"
|
|
446
|
-
>
|
|
447
|
-
<UInput
|
|
448
|
-
v-model="keyAddForm.path"
|
|
449
|
-
class="w-full"
|
|
450
|
-
placeholder="menu.home.title"
|
|
451
|
-
/>
|
|
452
|
-
</UFormField>
|
|
453
|
-
</template>
|
|
454
|
-
<template #footer>
|
|
455
|
-
<div class="flex w-full justify-end gap-2">
|
|
456
|
-
<UButton
|
|
457
|
-
color="neutral"
|
|
458
|
-
variant="ghost"
|
|
459
|
-
:label="$t('dms_lang.translation.ws_cancel')"
|
|
460
|
-
@click="keyAddOpen = false"
|
|
461
|
-
/>
|
|
462
|
-
<UButton
|
|
463
|
-
:label="$t('dms_lang.translation.ws_add')"
|
|
464
|
-
@click="submitAddKey"
|
|
465
|
-
/>
|
|
466
|
-
</div>
|
|
467
|
-
</template>
|
|
468
|
-
</UModal>
|
|
469
|
-
|
|
470
|
-
<UModal
|
|
471
|
-
v-model:open="keyRenameOpen"
|
|
472
|
-
:title="$t('dms_lang.translation.ws_rename_key')"
|
|
473
|
-
>
|
|
474
|
-
<template #body>
|
|
475
|
-
<UFormField
|
|
476
|
-
:label="$t('dms_lang.translation.ws_new_path')"
|
|
477
|
-
:help="$t('dms_lang.translation.ws_key_path_help')"
|
|
478
|
-
>
|
|
479
|
-
<UInput v-model="keyRenameForm.newPath" class="w-full" />
|
|
480
|
-
</UFormField>
|
|
481
|
-
</template>
|
|
482
|
-
<template #footer>
|
|
483
|
-
<div class="flex w-full justify-end gap-2">
|
|
484
|
-
<UButton
|
|
485
|
-
color="neutral"
|
|
486
|
-
variant="ghost"
|
|
487
|
-
:label="$t('dms_lang.translation.ws_cancel')"
|
|
488
|
-
@click="keyRenameOpen = false"
|
|
489
|
-
/>
|
|
490
|
-
<UButton
|
|
491
|
-
:label="$t('dms_lang.translation.ws_save')"
|
|
492
|
-
@click="submitRenameKey"
|
|
493
|
-
/>
|
|
494
|
-
</div>
|
|
495
|
-
</template>
|
|
496
|
-
</UModal>
|
|
497
|
-
</div>
|
|
498
|
-
</template>
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { defineDmsPlugin } from '#dms/frontend-module'
|
|
2
|
-
|
|
3
|
-
const LANG_MODULE_ID = 'lang'
|
|
4
|
-
|
|
5
|
-
export default defineDmsPlugin(() => {
|
|
6
|
-
const { register } = useSidebarWidgets()
|
|
7
|
-
register({
|
|
8
|
-
id: 'dms-lang:workspace-selector',
|
|
9
|
-
component: 'DmsLangWorkspaceSelector',
|
|
10
|
-
module: LANG_MODULE_ID,
|
|
11
|
-
})
|
|
12
|
-
})
|