@antelopejs/dms-lang 0.4.1 → 0.5.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.
Files changed (82) hide show
  1. package/README.md +16 -7
  2. package/dist/pages/workspace.js.map +1 -1
  3. package/dist/routes/publicLocales.js +1 -1
  4. package/dist/routes/publicLocales.js.map +1 -1
  5. package/dist/utils/announce.js +2 -1
  6. package/dist/utils/announce.js.map +1 -1
  7. package/dist/utils/body.js +5 -1
  8. package/dist/utils/body.js.map +1 -1
  9. package/dist/utils/cache.d.ts +1 -1
  10. package/dist/utils/cache.js +11 -9
  11. package/dist/utils/cache.js.map +1 -1
  12. package/dist/utils/errors.d.ts +5 -1
  13. package/dist/utils/errors.js.map +1 -1
  14. package/dist/utils/export.d.ts +2 -2
  15. package/dist/utils/export.js +8 -6
  16. package/dist/utils/export.js.map +1 -1
  17. package/dist/utils/guards.d.ts +3 -0
  18. package/dist/utils/guards.js +15 -0
  19. package/dist/utils/guards.js.map +1 -0
  20. package/dist/utils/json.d.ts +16 -10
  21. package/dist/utils/json.js +48 -20
  22. package/dist/utils/json.js.map +1 -1
  23. package/dist/utils/keys.d.ts +7 -6
  24. package/dist/utils/keys.js +4 -3
  25. package/dist/utils/keys.js.map +1 -1
  26. package/dist/utils/message-check.d.ts +2 -1
  27. package/dist/utils/message-check.js +7 -8
  28. package/dist/utils/message-check.js.map +1 -1
  29. package/dist/utils/public-url.d.ts +1 -0
  30. package/dist/utils/public-url.js +8 -8
  31. package/dist/utils/public-url.js.map +1 -1
  32. package/dist/utils/registry.d.ts +2 -2
  33. package/dist/utils/registry.js +2 -1
  34. package/dist/utils/registry.js.map +1 -1
  35. package/dist/utils/resolve.js +2 -1
  36. package/dist/utils/resolve.js.map +1 -1
  37. package/dist/utils/review.d.ts +2 -2
  38. package/dist/utils/review.js +2 -1
  39. package/dist/utils/review.js.map +1 -1
  40. package/dist/utils/snippets.js +2 -2
  41. package/dist/utils/snippets.js.map +1 -1
  42. package/dist/utils/tree.d.ts +7 -5
  43. package/dist/utils/tree.js +13 -7
  44. package/dist/utils/tree.js.map +1 -1
  45. package/dist/utils/workspaces.d.ts +3 -3
  46. package/dist/utils/workspaces.js +13 -6
  47. package/dist/utils/workspaces.js.map +1 -1
  48. package/dist/utils/write-target.d.ts +2 -1
  49. package/dist/utils/write-target.js +2 -2
  50. package/dist/utils/write-target.js.map +1 -1
  51. package/dist/validation/validate.js +1 -3
  52. package/dist/validation/validate.js.map +1 -1
  53. package/dist/validation/workspace.schema.d.ts +4 -3
  54. package/dist/validation/workspace.schema.js +5 -1
  55. package/dist/validation/workspace.schema.js.map +1 -1
  56. package/frontend-vue/app/build/components/KeyEditorDrawer.vue +28 -264
  57. package/frontend-vue/app/build/components/matrix/MatrixColumns.vue +1 -4
  58. package/frontend-vue/app/build/composables/useCellSaves.ts +12 -16
  59. package/frontend-vue/app/build/composables/useMatrixExport.ts +97 -0
  60. package/frontend-vue/app/build/composables/useQueueSave.ts +8 -3
  61. package/frontend-vue/app/build/composables/useQueueToasts.ts +7 -4
  62. package/frontend-vue/app/build/drawer/KeyLanguageField.vue +308 -0
  63. package/frontend-vue/app/build/drawer/fieldStatus.ts +11 -0
  64. package/frontend-vue/app/build/matrix/MatrixDoneBanner.vue +36 -0
  65. package/frontend-vue/app/build/matrix/MatrixFooter.vue +61 -0
  66. package/frontend-vue/app/build/matrix/MatrixLanguageHeader.vue +52 -0
  67. package/frontend-vue/app/build/matrix/MatrixNoRows.vue +68 -0
  68. package/frontend-vue/app/components/LanguageNamespaces.vue +1 -1
  69. package/frontend-vue/app/components/NamespaceCoverage.vue +1 -1
  70. package/frontend-vue/app/components/TranslationMatrix.vue +40 -225
  71. package/frontend-vue/app/components/WorkspaceList.vue +1 -1
  72. package/frontend-vue/app/composables/translation/useMutationToast.ts +9 -12
  73. package/frontend-vue/app/composables/translation/useWorkspaceActions.ts +8 -4
  74. package/frontend-vue/app/composables/translation/useWorkspaceFlat.ts +1 -1
  75. package/frontend-vue/app/utils/coverage.ts +139 -0
  76. package/frontend-vue/app/utils/translations.ts +1 -133
  77. package/frontend-vue/build/backend-boundary.ts +122 -0
  78. package/frontend-vue/dms.frontend.build.ts +3 -0
  79. package/frontend-vue/package.json +4 -4
  80. package/package.json +21 -10
  81. package/skills/dms-lang/SKILL.md +1 -1
  82. package/skills/dms-lang/cases.json +47 -0
@@ -0,0 +1,97 @@
1
+ import type { Ref } from 'vue'
2
+ import UButton from '@nuxt/ui/components/Button.vue'
3
+ import UDropdownMenu from '@nuxt/ui/components/DropdownMenu.vue'
4
+ import type { FlatTranslationRow, FlatTranslations } from '../../types/lang'
5
+ import { exportFileName, translationsCsv } from '../../utils/matrixExport'
6
+
7
+ interface MatrixExportOptions {
8
+ t: ReturnType<typeof useI18n>['t']
9
+ formatCount: (value: number) => string
10
+ flat: Readonly<Ref<FlatTranslations>>
11
+ rows: Readonly<Ref<FlatTranslationRow[]>>
12
+ columnCodes: Readonly<Ref<string[]>>
13
+ order: Readonly<Ref<string[]>>
14
+ selectedWorkspace: Readonly<Ref<string>>
15
+ isLoaded: Readonly<Ref<boolean>>
16
+ }
17
+
18
+ /**
19
+ * The export menu of the matrix in the page header: the keys and languages
20
+ * the matrix shows, or the whole workspace, as a CSV file.
21
+ */
22
+ export function useMatrixExport({
23
+ t,
24
+ formatCount,
25
+ flat,
26
+ rows,
27
+ columnCodes,
28
+ order,
29
+ selectedWorkspace,
30
+ isLoaded,
31
+ }: MatrixExportOptions) {
32
+ function exportCsv(isView: boolean) {
33
+ const base = flat.value.defaultLocale
34
+ const ordered = isView
35
+ ? columnCodes.value
36
+ : [...new Set([...order.value, ...flat.value.locales])].filter((code) =>
37
+ flat.value.locales.includes(code),
38
+ )
39
+ const locales = [base, ...ordered.filter((code) => code !== base)]
40
+ const content = translationsCsv(
41
+ isView ? rows.value : flat.value.rows,
42
+ locales,
43
+ )
44
+ downloadText(
45
+ exportFileName(selectedWorkspace.value, isView ? locales : undefined),
46
+ content,
47
+ 'text/csv;charset=utf-8',
48
+ )
49
+ }
50
+
51
+ function keysLabel(count: number): string {
52
+ return t('dms_lang.matrix.group_keys', { count: formatCount(count) }, count)
53
+ }
54
+
55
+ function languagesLabel(count: number): string {
56
+ return t('dms_lang.matrix.languages_counted', { count }, count)
57
+ }
58
+
59
+ usePageHeaderActions(
60
+ () => [
61
+ h(
62
+ UDropdownMenu,
63
+ {
64
+ items: [
65
+ {
66
+ label: t('dms_lang.matrix.export_view', {
67
+ keys: keysLabel(rows.value.length),
68
+ languages: languagesLabel(columnCodes.value.length),
69
+ }),
70
+ icon: 'i-ph-funnel',
71
+ onSelect: () => exportCsv(true),
72
+ },
73
+ {
74
+ label: t('dms_lang.matrix.export_all', {
75
+ keys: keysLabel(flat.value.rows.length),
76
+ languages: languagesLabel(flat.value.locales.length),
77
+ }),
78
+ icon: 'i-ph-table',
79
+ onSelect: () => exportCsv(false),
80
+ },
81
+ ],
82
+ content: { align: 'end' },
83
+ },
84
+ () =>
85
+ h(UButton, {
86
+ label: t('dms_lang.matrix.export'),
87
+ icon: 'i-ph-download-simple',
88
+ trailingIcon: 'i-ph-caret-down',
89
+ color: 'neutral',
90
+ variant: 'outline',
91
+ disabled: !isLoaded.value,
92
+ }),
93
+ ),
94
+ ],
95
+ { order: -1 },
96
+ )
97
+ }
@@ -81,15 +81,20 @@ function onInvalid(
81
81
  }
82
82
 
83
83
  const SAVE_FAILURES: Record<KeySaveFailureKind, SaveFailureHandler> = {
84
- conflict: (context, write) => context.toasts.warnConflict(write.row.key),
84
+ conflict: (context, write, outcome) =>
85
+ context.failures.reportFailure(outcome.error, {
86
+ fallbackKey: 'dms_lang.queue.conflict_description',
87
+ params: { key: write.row.key },
88
+ }),
85
89
  deleted: (context, write) => onDeleted(context, write.row),
86
90
  invalid: onInvalid,
87
91
  other: (context, write, outcome) =>
88
92
  context.failures.reportFailure(outcome.error, {
89
- title: context.t('dms_lang.matrix.save_failed', {
93
+ fallbackKey: 'dms_lang.matrix.save_failed',
94
+ params: {
90
95
  key: write.row.key,
91
96
  code: context.session.locale.value,
92
- }),
97
+ },
93
98
  retry: () => void send(context, write),
94
99
  }),
95
100
  }
@@ -14,10 +14,13 @@ const STEP_TOASTS: Partial<Record<QueueStep, string>> = {
14
14
  }
15
15
 
16
16
  async function copyText({ t, toast }: ToastContext, value: string) {
17
- try {
18
- await navigator.clipboard.writeText(value)
17
+ const copied = await navigator.clipboard.writeText(value).then(
18
+ () => true,
19
+ () => false,
20
+ )
21
+ if (copied) {
19
22
  toast.add({ title: t('dms_lang.queue.copied'), color: 'success' })
20
- } catch {
23
+ } else {
21
24
  toast.add({
22
25
  title: t('dms_lang.queue.copy_failed'),
23
26
  description: value,
@@ -68,7 +71,7 @@ function showStep({ t, toast }: ToastContext, step: QueueStep | undefined) {
68
71
  function warnBlocked({ t, toast }: ToastContext) {
69
72
  toast.add({
70
73
  title: t('dms_lang.queue.blocked'),
71
- color: 'error',
74
+ color: 'warning',
72
75
  icon: 'i-ph-warning-circle',
73
76
  })
74
77
  }
@@ -0,0 +1,308 @@
1
+ <script setup lang="ts">
2
+ import type { FlatTranslationRow } from '../../types/lang'
3
+ import type { SaveState } from '../../utils/keySaves'
4
+ import {
5
+ escapeMessage,
6
+ formatTokens,
7
+ messageIssueText,
8
+ replacePlaceholder,
9
+ type MessageIssue,
10
+ type MessageTranslate,
11
+ } from '../../utils/translations'
12
+ import LocaleTile from '../components/LocaleTile.vue'
13
+ import PlaceholderText from '../components/PlaceholderText.vue'
14
+ import {
15
+ BASE_MISSING_LABEL,
16
+ FIELD_STATUS_LABELS,
17
+ type FieldStatus,
18
+ } from './fieldStatus'
19
+
20
+ /**
21
+ * The field of one language in the key panel (`KeyEditorDrawer`): its name
22
+ * and status, its text, a conflict or an error, and its issues. The panel
23
+ * keeps the state and hands its readers and actions down.
24
+ */
25
+ const props = defineProps<{
26
+ code: string
27
+ base: string
28
+ baseText: string
29
+ row: FlatTranslationRow
30
+ fieldErrors: Record<string, string>
31
+ editable: boolean
32
+ t: MessageTranslate
33
+ nativeName: (code: string) => string
34
+ fieldIdOf: (code: string) => string
35
+ hasConflict: (code: string) => boolean
36
+ saveStateOf: (code: string) => SaveState
37
+ statusOf: (code: string) => FieldStatus
38
+ issuesOf: (code: string) => MessageIssue[]
39
+ issueOfKind: (
40
+ code: string,
41
+ kind: MessageIssue['kind'],
42
+ ) => MessageIssue | undefined
43
+ draftOf: (code: string) => string
44
+ ownOf: (code: string) => string
45
+ save: (codes: string[]) => Promise<boolean>
46
+ setDraft: (code: string, value: string) => void
47
+ discardDraft: (code: string) => void
48
+ overwrite: (code: string) => void
49
+ markReviewed: (code: string) => Promise<void>
50
+ insertAtCaret: (code: string, token: string) => void
51
+ rewrite: (code: string, value: string) => void
52
+ onFieldBlur: (code: string) => void
53
+ saveAndNext: () => Promise<void>
54
+ }>()
55
+ </script>
56
+
57
+ <template>
58
+ <div class="flex flex-wrap items-center gap-x-2 gap-y-1 text-sm">
59
+ <LocaleTile :code="code" size="sm" :is-base="code === base" />
60
+ <label
61
+ v-if="props.editable"
62
+ :for="fieldIdOf(code)"
63
+ class="text-highlighted font-medium"
64
+ >
65
+ {{ nativeName(code) }}
66
+ </label>
67
+ <span v-else class="text-highlighted font-medium">
68
+ {{ nativeName(code) }}
69
+ </span>
70
+ <span class="text-dimmed font-mono text-xs">{{ code }}</span>
71
+ <DmsStatusPill
72
+ v-if="code === base"
73
+ dot="none"
74
+ tone="neutral"
75
+ size="sm"
76
+ :label="$t('dms_lang.common.base')"
77
+ />
78
+ <span class="ml-auto inline-flex items-center gap-1.5 text-xs">
79
+ <span
80
+ v-if="hasConflict(code)"
81
+ class="text-error inline-flex items-center gap-1 font-medium"
82
+ >
83
+ <UIcon name="i-ph-warning" class="size-3.5" />
84
+ {{ $t('dms_lang.drawer.conflict') }}
85
+ </span>
86
+ <template v-else-if="saveStateOf(code) !== 'idle'">
87
+ <DmsSaveStatus
88
+ :state="saveStateOf(code)"
89
+ @retry="save([code])"
90
+ />
91
+ <UButton
92
+ v-if="saveStateOf(code) === 'error'"
93
+ size="xs"
94
+ color="neutral"
95
+ variant="link"
96
+ :label="$t('dms_lang.drawer.discard')"
97
+ @click="discardDraft(code)"
98
+ />
99
+ </template>
100
+ <span
101
+ v-else-if="statusOf(code) === 'missing'"
102
+ class="text-warning font-mono font-semibold uppercase"
103
+ >
104
+ {{
105
+ $t(
106
+ code === base
107
+ ? BASE_MISSING_LABEL
108
+ : FIELD_STATUS_LABELS.missing,
109
+ )
110
+ }}
111
+ </span>
112
+ <template v-else-if="statusOf(code) !== 'done'">
113
+ <span
114
+ :class="
115
+ statusOf(code) === 'outdated'
116
+ ? 'text-warning font-medium'
117
+ : 'text-dimmed'
118
+ "
119
+ >
120
+ {{ $t(FIELD_STATUS_LABELS[statusOf(code)]) }}
121
+ </span>
122
+ <UButton
123
+ v-if="statusOf(code) === 'overridden' && props.editable"
124
+ size="xs"
125
+ color="neutral"
126
+ variant="link"
127
+ :label="$t('dms_lang.drawer.use_module')"
128
+ @click="(setDraft(code, ''), save([code]))"
129
+ />
130
+ <UButton
131
+ v-else-if="statusOf(code) === 'outdated' && props.editable"
132
+ size="xs"
133
+ color="neutral"
134
+ variant="link"
135
+ icon="i-ph-check"
136
+ :label="$t('dms_lang.drawer.mark_reviewed')"
137
+ @click="markReviewed(code)"
138
+ />
139
+ </template>
140
+ <UIcon
141
+ v-else-if="code !== base && !issuesOf(code).length"
142
+ name="i-ph-check"
143
+ class="text-success size-4"
144
+ />
145
+ </span>
146
+ </div>
147
+ <UTextarea
148
+ v-if="props.editable"
149
+ :id="fieldIdOf(code)"
150
+ :model-value="draftOf(code)"
151
+ autoresize
152
+ :rows="1"
153
+ :maxrows="10"
154
+ class="w-full"
155
+ :color="issuesOf(code).length ? 'error' : undefined"
156
+ :highlight="issuesOf(code).length > 0"
157
+ @update:model-value="(value: string) => setDraft(code, value)"
158
+ @blur="onFieldBlur(code)"
159
+ @keydown.meta.enter.prevent="saveAndNext"
160
+ @keydown.ctrl.enter.prevent="saveAndNext"
161
+ />
162
+ <div
163
+ v-else
164
+ class="border-default rounded-md border bg-(--dms-bg-muted) px-3 py-2 text-sm"
165
+ >
166
+ <PlaceholderText v-if="draftOf(code)" :text="draftOf(code)" />
167
+ <span v-else class="text-dimmed">—</span>
168
+ <p
169
+ v-if="row.overrides?.[code]"
170
+ class="text-dimmed border-default mt-2 border-t pt-2 text-xs"
171
+ >
172
+ {{ $t('dms_lang.drawer.project_value') }}
173
+ <PlaceholderText
174
+ :text="row.overrides[code]"
175
+ class="text-default"
176
+ />
177
+ </p>
178
+ </div>
179
+ <div
180
+ v-if="hasConflict(code)"
181
+ class="border-error/40 space-y-1.5 rounded-md border px-3 py-2 text-xs"
182
+ >
183
+ <p class="text-dimmed">
184
+ <template v-if="ownOf(code)">
185
+ {{ $t('dms_lang.drawer.conflict_value') }}
186
+ <PlaceholderText :text="ownOf(code)" class="text-default" />
187
+ </template>
188
+ <template v-else>
189
+ {{ $t('dms_lang.drawer.conflict_empty') }}
190
+ </template>
191
+ </p>
192
+ <p class="text-dimmed">{{ $t('dms_lang.drawer.conflict_help') }}</p>
193
+ <div class="flex flex-wrap gap-1.5">
194
+ <UButton
195
+ size="xs"
196
+ color="error"
197
+ variant="soft"
198
+ :label="$t('dms_lang.drawer.overwrite')"
199
+ @mousedown.prevent
200
+ @click="overwrite(code)"
201
+ />
202
+ <UButton
203
+ size="xs"
204
+ color="neutral"
205
+ variant="outline"
206
+ :label="$t('dms_lang.drawer.discard')"
207
+ @mousedown.prevent
208
+ @click="discardDraft(code)"
209
+ />
210
+ </div>
211
+ </div>
212
+ <p v-else-if="fieldErrors[code]" class="text-error text-xs">
213
+ {{ fieldErrors[code] }}
214
+ </p>
215
+ <div
216
+ v-if="props.editable && issuesOf(code).length"
217
+ class="space-y-1 text-xs"
218
+ >
219
+ <div
220
+ v-for="issue in issuesOf(code)"
221
+ :key="issue.kind"
222
+ class="flex flex-wrap items-center gap-x-3 gap-y-1"
223
+ >
224
+ <span
225
+ :class="
226
+ issue.severity === 'error' ? 'text-error' : 'text-warning'
227
+ "
228
+ >
229
+ {{ messageIssueText(issue, t) }}
230
+ <template v-if="issue.kind === 'missing'">
231
+ {{
232
+ $t(
233
+ 'dms_lang.drawer.issue_help',
234
+ { tokens: formatTokens(issue.tokens) },
235
+ issue.count,
236
+ )
237
+ }}
238
+ </template>
239
+ </span>
240
+ <template v-if="issue.kind === 'missing'">
241
+ <UButton
242
+ v-for="token in issue.tokens"
243
+ :key="token"
244
+ size="xs"
245
+ color="error"
246
+ variant="soft"
247
+ :label="
248
+ $t('dms_lang.drawer.insert', {
249
+ token: formatTokens([token]),
250
+ })
251
+ "
252
+ @mousedown.prevent
253
+ @click="insertAtCaret(code, formatTokens([token]))"
254
+ />
255
+ <UButton
256
+ v-if="
257
+ issue.tokens.length === 1 &&
258
+ issueOfKind(code, 'extra')?.tokens.length === 1
259
+ "
260
+ size="xs"
261
+ color="error"
262
+ variant="soft"
263
+ :label="
264
+ $t('dms_lang.message_issue.replace', {
265
+ token: formatTokens(issue.tokens),
266
+ })
267
+ "
268
+ @mousedown.prevent
269
+ @click="
270
+ rewrite(
271
+ code,
272
+ replacePlaceholder(
273
+ draftOf(code),
274
+ issueOfKind(code, 'extra')?.tokens[0] ?? '',
275
+ issue.tokens[0],
276
+ ),
277
+ )
278
+ "
279
+ />
280
+ </template>
281
+ <UButton
282
+ v-else-if="
283
+ issue.severity === 'error' &&
284
+ escapeMessage(draftOf(code)) !== draftOf(code)
285
+ "
286
+ size="xs"
287
+ color="error"
288
+ variant="soft"
289
+ icon="i-ph-magic-wand"
290
+ :label="$t('dms_lang.message_issue.escape')"
291
+ @mousedown.prevent
292
+ @click="rewrite(code, escapeMessage(draftOf(code)))"
293
+ />
294
+ </div>
295
+ </div>
296
+ <p
297
+ v-else-if="
298
+ props.editable &&
299
+ code !== base &&
300
+ baseText &&
301
+ statusOf(code) === 'missing'
302
+ "
303
+ class="text-dimmed text-xs"
304
+ >
305
+ {{ $t('dms_lang.drawer.reference') }}
306
+ <PlaceholderText :text="baseText" />
307
+ </p>
308
+ </template>
@@ -0,0 +1,11 @@
1
+ export type FieldStatus =
2
+ 'missing' | 'inherited' | 'overridden' | 'outdated' | 'done'
3
+
4
+ export const BASE_MISSING_LABEL = 'dms_lang.matrix.source_missing'
5
+ export const FIELD_STATUS_LABELS: Record<FieldStatus, string> = {
6
+ missing: 'dms_lang.matrix.missing',
7
+ inherited: 'dms_lang.drawer.inherited',
8
+ overridden: 'dms_lang.drawer.overridden',
9
+ outdated: 'dms_lang.drawer.outdated',
10
+ done: '',
11
+ }
@@ -0,0 +1,36 @@
1
+ <script setup lang="ts">
2
+ import UButton from '@nuxt/ui/components/Button.vue'
3
+
4
+ /** The banner of the matrix over the rows finished since it opened: how many, and hiding them. */
5
+ defineProps<{
6
+ doneCount: number
7
+ formatCount: (value: number) => string
8
+ hideDone: () => void
9
+ }>()
10
+ </script>
11
+
12
+ <template>
13
+ <div
14
+ class="border-default bg-success/5 flex flex-wrap items-center gap-2 border-b px-4 py-2 text-sm"
15
+ role="status"
16
+ >
17
+ <UIcon name="i-ph-check-circle" class="text-success size-4" />
18
+ <span class="text-default">
19
+ {{
20
+ $t(
21
+ 'dms_lang.matrix.done_banner',
22
+ { count: formatCount(doneCount) },
23
+ doneCount,
24
+ )
25
+ }}
26
+ </span>
27
+ <UButton
28
+ size="xs"
29
+ color="neutral"
30
+ variant="outline"
31
+ class="ml-auto"
32
+ :label="$t('dms_lang.matrix.hide_done')"
33
+ @click="hideDone"
34
+ />
35
+ </div>
36
+ </template>
@@ -0,0 +1,61 @@
1
+ <script setup lang="ts">
2
+ import { MATRIX_KEYS } from '../../utils/shortcuts'
3
+ import ShortcutKbds from '../components/ShortcutKbds.vue'
4
+ import type { MatrixCounts } from '../composables/useMatrixFilters'
5
+
6
+ /** The foot of the matrix: what is left to translate, and the keyboard shortcuts of its cells. */
7
+ defineProps<{
8
+ counts: MatrixCounts
9
+ countedLabel: string
10
+ canEditValues: boolean
11
+ isCompact: boolean
12
+ formatCount: (value: number) => string
13
+ }>()
14
+ </script>
15
+
16
+ <template>
17
+ <div
18
+ class="border-default text-dimmed flex flex-wrap items-center gap-x-4 gap-y-1 border-t px-4 py-2 text-xs"
19
+ >
20
+ <span>
21
+ {{
22
+ $t(
23
+ 'dms_lang.matrix.footer_keys',
24
+ { count: formatCount(counts.missing) },
25
+ counts.missing,
26
+ )
27
+ }}
28
+ ·
29
+ {{
30
+ $t(
31
+ 'dms_lang.matrix.footer_cells',
32
+ { count: formatCount(counts.cells), languages: countedLabel },
33
+ counts.cells,
34
+ )
35
+ }}
36
+ </span>
37
+ <span
38
+ v-if="canEditValues && !isCompact"
39
+ class="ml-auto inline-flex flex-wrap items-center gap-3"
40
+ >
41
+ <span class="inline-flex items-center gap-1">
42
+ <ShortcutKbds :keys="MATRIX_KEYS.saveDown" />
43
+ {{ $t('dms_lang.matrix.shortcut_save_down') }}
44
+ </span>
45
+ <span class="inline-flex items-center gap-1">
46
+ <ShortcutKbds :keys="MATRIX_KEYS.nextCell" />
47
+ {{ $t('dms_lang.matrix.shortcut_next_cell') }}
48
+ </span>
49
+ <span class="inline-flex items-center gap-1">
50
+ <ShortcutKbds :keys="MATRIX_KEYS.nextMissing" />
51
+ /
52
+ <ShortcutKbds :keys="MATRIX_KEYS.previousMissing" />
53
+ {{ $t('dms_lang.matrix.shortcut_next_missing') }}
54
+ </span>
55
+ <span class="inline-flex items-center gap-1">
56
+ <ShortcutKbds :keys="MATRIX_KEYS.openPanel" />
57
+ {{ $t('dms_lang.matrix.open_panel') }}
58
+ </span>
59
+ </span>
60
+ </div>
61
+ </template>
@@ -0,0 +1,52 @@
1
+ <script setup lang="ts">
2
+ import type { LanguageCoverage } from '../../types/lang'
3
+ import { coverageTone } from '../../utils/coverage'
4
+ import LocaleTile from '../components/LocaleTile.vue'
5
+
6
+ /** The head of a language column of the matrix: the language, its missing texts and its coverage. */
7
+ defineProps<{
8
+ column: LanguageCoverage
9
+ columnSiblings: string[]
10
+ formatCount: (value: number) => string
11
+ }>()
12
+ </script>
13
+
14
+ <template>
15
+ <div class="flex items-center gap-2">
16
+ <LocaleTile
17
+ :code="column.code"
18
+ size="sm"
19
+ :is-base="column.isBase"
20
+ :siblings="columnSiblings"
21
+ />
22
+ <span class="text-highlighted truncate font-medium">
23
+ {{ column.name }}
24
+ </span>
25
+ <DmsStatusPill
26
+ v-if="column.isBase"
27
+ dot="none"
28
+ tone="neutral"
29
+ size="sm"
30
+ :label="$t('dms_lang.common.base')"
31
+ />
32
+ <span
33
+ v-else
34
+ class="text-dimmed ml-auto font-mono text-[10.5px] whitespace-nowrap"
35
+ >
36
+ {{
37
+ $t(
38
+ 'dms_lang.matrix.column_missing',
39
+ { count: formatCount(column.missing) },
40
+ column.missing,
41
+ )
42
+ }}
43
+ </span>
44
+ </div>
45
+ <DmsMeter
46
+ class="mt-2"
47
+ :value="column.coverage"
48
+ :max="100"
49
+ size="xs"
50
+ :tone="column.isBase ? 'primary' : coverageTone(column.coverage)"
51
+ />
52
+ </template>
@@ -0,0 +1,68 @@
1
+ <script setup lang="ts">
2
+ import type { FlatTranslations } from '../../types/lang'
3
+ import type { MatrixFilterState } from '../composables/useMatrixFilters'
4
+
5
+ /**
6
+ * The matrix with no row to show: no key matches the filters (show them all),
7
+ * or the workspace has no key yet (add one).
8
+ */
9
+ defineProps<{
10
+ flat: FlatTranslations
11
+ filters: MatrixFilterState
12
+ canManageKeys: boolean
13
+ formatCount: (value: number) => string
14
+ resetFilters: () => void
15
+ addKey: () => unknown
16
+ }>()
17
+ </script>
18
+
19
+ <template>
20
+ <DmsEmptyState
21
+ :variant="flat.rows.length ? 'no-result' : 'no-data'"
22
+ size="lg"
23
+ hatched
24
+ :title="
25
+ flat.rows.length
26
+ ? $t('dms_lang.matrix.no_match', { search: filters.search })
27
+ : $t('dms_lang.matrix.no_keys')
28
+ "
29
+ :description="
30
+ flat.rows.length
31
+ ? $t(
32
+ 'dms_lang.matrix.no_match_description',
33
+ { count: formatCount(flat.rows.length) },
34
+ flat.rows.length,
35
+ )
36
+ : $t('dms_lang.matrix.no_keys_description')
37
+ "
38
+ :actions="[
39
+ ...(flat.rows.length
40
+ ? [
41
+ {
42
+ label: $t(
43
+ 'dms_lang.matrix.show_all',
44
+ { count: formatCount(flat.rows.length) },
45
+ flat.rows.length,
46
+ ),
47
+ color: 'neutral',
48
+ variant: 'outline',
49
+ onClick: resetFilters,
50
+ },
51
+ ]
52
+ : []),
53
+ ...(canManageKeys
54
+ ? [
55
+ {
56
+ label: filters.search
57
+ ? $t('dms_lang.matrix.add_named', { key: filters.search })
58
+ : $t('dms_lang.key_add.title'),
59
+ icon: 'i-ph-plus',
60
+ color: 'neutral',
61
+ variant: 'ghost',
62
+ onClick: () => addKey(),
63
+ },
64
+ ]
65
+ : []),
66
+ ]"
67
+ />
68
+ </template>
@@ -1,6 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import { useWorkspaceFlatSync } from '../composables/translation/useWorkspaceFlat'
3
- import { coverageTone } from '../utils/translations'
3
+ import { coverageTone } from '../utils/coverage'
4
4
 
5
5
  const { isLoaded } = useWorkspaceFlat()
6
6
  useWorkspaceFlatSync()