@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.
Files changed (245) hide show
  1. package/README.md +12 -6
  2. package/dist/pages/actions.d.ts +7 -0
  3. package/dist/pages/actions.js +15 -0
  4. package/dist/pages/actions.js.map +1 -0
  5. package/dist/pages/component-action.d.ts +2 -0
  6. package/dist/pages/component-action.js +10 -0
  7. package/dist/pages/component-action.js.map +1 -0
  8. package/dist/pages/header-actions.d.ts +9 -0
  9. package/dist/pages/header-actions.js +146 -0
  10. package/dist/pages/header-actions.js.map +1 -0
  11. package/dist/pages/index.d.ts +6 -0
  12. package/dist/pages/index.js +6 -0
  13. package/dist/pages/index.js.map +1 -1
  14. package/dist/pages/language.d.ts +10 -0
  15. package/dist/pages/language.js +89 -0
  16. package/dist/pages/language.js.map +1 -0
  17. package/dist/pages/languages-table.d.ts +2 -0
  18. package/dist/pages/languages-table.js +120 -0
  19. package/dist/pages/languages-table.js.map +1 -0
  20. package/dist/pages/module.d.ts +7 -1
  21. package/dist/pages/module.js +28 -2
  22. package/dist/pages/module.js.map +1 -1
  23. package/dist/pages/overview.d.ts +2 -1
  24. package/dist/pages/overview.js +83 -8
  25. package/dist/pages/overview.js.map +1 -1
  26. package/dist/pages/page-actions.d.ts +6 -0
  27. package/dist/pages/page-actions.js +10 -0
  28. package/dist/pages/page-actions.js.map +1 -0
  29. package/dist/pages/quick-actions.d.ts +1 -0
  30. package/dist/pages/quick-actions.js +56 -0
  31. package/dist/pages/quick-actions.js.map +1 -0
  32. package/dist/pages/translations.d.ts +7 -1
  33. package/dist/pages/translations.js +47 -10
  34. package/dist/pages/translations.js.map +1 -1
  35. package/dist/pages/workspace-guard.d.ts +1 -0
  36. package/dist/pages/workspace-guard.js +35 -0
  37. package/dist/pages/workspace-guard.js.map +1 -0
  38. package/dist/pages/workspace.d.ts +18 -0
  39. package/dist/pages/workspace.js +162 -0
  40. package/dist/pages/workspace.js.map +1 -0
  41. package/dist/pages/workspaces.d.ts +14 -0
  42. package/dist/pages/workspaces.js +88 -0
  43. package/dist/pages/workspaces.js.map +1 -0
  44. package/dist/routes/publicLocales.d.ts +3 -2
  45. package/dist/routes/publicLocales.js +39 -18
  46. package/dist/routes/publicLocales.js.map +1 -1
  47. package/dist/routes/translations.d.ts +59 -63
  48. package/dist/routes/translations.js +400 -119
  49. package/dist/routes/translations.js.map +1 -1
  50. package/dist/utils/announce.d.ts +9 -0
  51. package/dist/utils/announce.js +29 -0
  52. package/dist/utils/announce.js.map +1 -0
  53. package/dist/utils/blocks.d.ts +8 -0
  54. package/dist/utils/blocks.js +213 -0
  55. package/dist/utils/blocks.js.map +1 -0
  56. package/dist/utils/body.d.ts +1 -0
  57. package/dist/utils/body.js +21 -0
  58. package/dist/utils/body.js.map +1 -0
  59. package/dist/utils/cache.d.ts +3 -0
  60. package/dist/utils/cache.js +32 -0
  61. package/dist/utils/cache.js.map +1 -0
  62. package/dist/utils/catalog.d.ts +7 -0
  63. package/dist/utils/catalog.js +62 -0
  64. package/dist/utils/catalog.js.map +1 -0
  65. package/dist/utils/constants.d.ts +6 -0
  66. package/dist/utils/constants.js +10 -0
  67. package/dist/utils/constants.js.map +1 -0
  68. package/dist/utils/coverage.d.ts +2 -0
  69. package/dist/utils/coverage.js +11 -0
  70. package/dist/utils/coverage.js.map +1 -0
  71. package/dist/utils/dialogs.d.ts +7 -0
  72. package/dist/utils/dialogs.js +103 -0
  73. package/dist/utils/dialogs.js.map +1 -0
  74. package/dist/utils/errors.d.ts +40 -0
  75. package/dist/utils/errors.js +60 -0
  76. package/dist/utils/errors.js.map +1 -0
  77. package/dist/utils/export.d.ts +17 -0
  78. package/dist/utils/export.js +129 -0
  79. package/dist/utils/export.js.map +1 -0
  80. package/dist/utils/json.d.ts +10 -1
  81. package/dist/utils/json.js +127 -19
  82. package/dist/utils/json.js.map +1 -1
  83. package/dist/utils/key-stores.d.ts +3 -0
  84. package/dist/utils/key-stores.js +24 -0
  85. package/dist/utils/key-stores.js.map +1 -0
  86. package/dist/utils/keys.d.ts +23 -0
  87. package/dist/utils/keys.js +252 -0
  88. package/dist/utils/keys.js.map +1 -0
  89. package/dist/utils/languages.d.ts +27 -0
  90. package/dist/utils/languages.js +121 -0
  91. package/dist/utils/languages.js.map +1 -0
  92. package/dist/utils/locale-codes.d.ts +5 -0
  93. package/dist/utils/locale-codes.js +56 -0
  94. package/dist/utils/locale-codes.js.map +1 -0
  95. package/dist/utils/locale-discovery.d.ts +1 -0
  96. package/dist/utils/locale-discovery.js +19 -1
  97. package/dist/utils/locale-discovery.js.map +1 -1
  98. package/dist/utils/message-check.d.ts +1 -0
  99. package/dist/utils/message-check.js +93 -0
  100. package/dist/utils/message-check.js.map +1 -0
  101. package/dist/utils/message-syntax.d.ts +6 -0
  102. package/dist/utils/message-syntax.js +38 -0
  103. package/dist/utils/message-syntax.js.map +1 -0
  104. package/dist/utils/namespaces.d.ts +12 -0
  105. package/dist/utils/namespaces.js +52 -0
  106. package/dist/utils/namespaces.js.map +1 -0
  107. package/dist/utils/notices.d.ts +4 -0
  108. package/dist/utils/notices.js +60 -0
  109. package/dist/utils/notices.js.map +1 -0
  110. package/dist/utils/own.d.ts +2 -3
  111. package/dist/utils/own.js +17 -57
  112. package/dist/utils/own.js.map +1 -1
  113. package/dist/utils/public-url.d.ts +8 -0
  114. package/dist/utils/public-url.js +87 -0
  115. package/dist/utils/public-url.js.map +1 -0
  116. package/dist/utils/registry.d.ts +3 -1
  117. package/dist/utils/registry.js +26 -10
  118. package/dist/utils/registry.js.map +1 -1
  119. package/dist/utils/resolve.d.ts +18 -15
  120. package/dist/utils/resolve.js +98 -151
  121. package/dist/utils/resolve.js.map +1 -1
  122. package/dist/utils/review.d.ts +5 -0
  123. package/dist/utils/review.js +64 -0
  124. package/dist/utils/review.js.map +1 -0
  125. package/dist/utils/snippets.d.ts +7 -0
  126. package/dist/utils/snippets.js +129 -0
  127. package/dist/utils/snippets.js.map +1 -0
  128. package/dist/utils/summary.d.ts +23 -0
  129. package/dist/utils/summary.js +65 -0
  130. package/dist/utils/summary.js.map +1 -0
  131. package/dist/utils/tree.d.ts +2 -17
  132. package/dist/utils/tree.js +21 -126
  133. package/dist/utils/tree.js.map +1 -1
  134. package/dist/utils/workspaces.d.ts +45 -15
  135. package/dist/utils/workspaces.js +256 -164
  136. package/dist/utils/workspaces.js.map +1 -1
  137. package/dist/validation/key.schema.d.ts +71 -0
  138. package/dist/validation/key.schema.js +67 -0
  139. package/dist/validation/key.schema.js.map +1 -0
  140. package/dist/validation/query.schema.d.ts +17 -0
  141. package/dist/validation/query.schema.js +44 -0
  142. package/dist/validation/query.schema.js.map +1 -0
  143. package/dist/validation/validate.d.ts +2 -0
  144. package/dist/validation/validate.js +24 -0
  145. package/dist/validation/validate.js.map +1 -0
  146. package/dist/validation/workspace.schema.d.ts +145 -0
  147. package/dist/validation/workspace.schema.js +83 -0
  148. package/dist/validation/workspace.schema.js.map +1 -0
  149. package/frontend-vue/app/build/components/KeyAddModal.vue +340 -0
  150. package/frontend-vue/app/build/components/KeyEditorDrawer.vue +951 -0
  151. package/frontend-vue/app/build/components/KeyRenameModal.vue +172 -0
  152. package/frontend-vue/app/build/components/LanguageAddModal.vue +199 -0
  153. package/frontend-vue/app/build/components/LanguagePicker.vue +233 -0
  154. package/frontend-vue/app/build/components/LocaleTile.vue +52 -0
  155. package/frontend-vue/app/build/components/PlaceholderText.vue +42 -0
  156. package/frontend-vue/app/build/components/ShortcutKbds.vue +22 -0
  157. package/frontend-vue/app/build/components/WorkspaceCreateModal.vue +193 -0
  158. package/frontend-vue/app/build/components/WorkspaceRenameModal.vue +107 -0
  159. package/frontend-vue/app/build/components/form/FormFieldRow.vue +70 -0
  160. package/frontend-vue/app/build/components/form/FormRows.vue +25 -0
  161. package/frontend-vue/app/build/components/form/WorkspaceDetailsFields.vue +44 -0
  162. package/frontend-vue/app/build/components/matrix/MatrixCell.vue +488 -0
  163. package/frontend-vue/app/build/components/matrix/MatrixColumns.vue +177 -0
  164. package/frontend-vue/app/build/components/matrix/MatrixGroupHeader.vue +57 -0
  165. package/frontend-vue/app/build/components/matrix/MatrixKeyCell.vue +83 -0
  166. package/frontend-vue/app/build/components/matrix/MatrixToolbar.vue +167 -0
  167. package/frontend-vue/app/build/components/queue/QueueActions.vue +60 -0
  168. package/frontend-vue/app/build/components/queue/QueueDone.vue +185 -0
  169. package/frontend-vue/app/build/components/queue/QueueEditor.vue +374 -0
  170. package/frontend-vue/app/build/components/queue/QueueHeader.vue +162 -0
  171. package/frontend-vue/app/build/components/queue/QueueUpNext.vue +61 -0
  172. package/frontend-vue/app/build/composables/useCellEditor.ts +324 -0
  173. package/frontend-vue/app/build/composables/useCellMoves.ts +155 -0
  174. package/frontend-vue/app/build/composables/useCellSaves.ts +339 -0
  175. package/frontend-vue/app/build/composables/useKeyPanel.ts +284 -0
  176. package/frontend-vue/app/build/composables/useKeySaves.ts +280 -0
  177. package/frontend-vue/app/build/composables/useMatrixFilters.ts +213 -0
  178. package/frontend-vue/app/build/composables/useMatrixRows.ts +104 -0
  179. package/frontend-vue/app/build/composables/useMatrixView.ts +181 -0
  180. package/frontend-vue/app/build/composables/useQueueContext.ts +31 -0
  181. package/frontend-vue/app/build/composables/useQueueEditing.ts +53 -0
  182. package/frontend-vue/app/build/composables/useQueueOrphans.ts +54 -0
  183. package/frontend-vue/app/build/composables/useQueueSave.ts +290 -0
  184. package/frontend-vue/app/build/composables/useQueueShortcuts.ts +106 -0
  185. package/frontend-vue/app/build/composables/useQueueToasts.ts +99 -0
  186. package/frontend-vue/app/components/LanguageNamespaces.vue +77 -0
  187. package/frontend-vue/app/components/NamespaceCoverage.vue +222 -0
  188. package/frontend-vue/app/components/TranslationMatrix.vue +809 -0
  189. package/frontend-vue/app/components/TranslationQueue.vue +212 -0
  190. package/frontend-vue/app/components/WorkspaceDangerZone.vue +81 -0
  191. package/frontend-vue/app/components/WorkspaceGeneral.vue +232 -0
  192. package/frontend-vue/app/components/WorkspaceList.vue +454 -0
  193. package/frontend-vue/app/components/WorkspaceScope.vue +384 -0
  194. package/frontend-vue/app/composables/translation/useFirstRun.ts +8 -0
  195. package/frontend-vue/app/composables/translation/useI18nWorkspaces.ts +221 -133
  196. package/frontend-vue/app/composables/translation/useKeyActions.ts +224 -0
  197. package/frontend-vue/app/composables/translation/useLangFormat.ts +10 -0
  198. package/frontend-vue/app/composables/translation/useLangLinks.ts +80 -0
  199. package/frontend-vue/app/composables/translation/useLanguageActions.ts +159 -0
  200. package/frontend-vue/app/composables/translation/useLanguageQueue.ts +232 -0
  201. package/frontend-vue/app/composables/translation/useLocaleNames.ts +166 -0
  202. package/frontend-vue/app/composables/translation/useMutationToast.ts +51 -17
  203. package/frontend-vue/app/composables/translation/useQueueDrafts.ts +115 -0
  204. package/frontend-vue/app/composables/translation/useQueueSession.ts +182 -0
  205. package/frontend-vue/app/composables/translation/useServedConfirm.ts +152 -0
  206. package/frontend-vue/app/composables/translation/useWorkspaceActions.ts +259 -0
  207. package/frontend-vue/app/composables/translation/useWorkspaceContext.ts +46 -15
  208. package/frontend-vue/app/composables/translation/useWorkspaceFlat.ts +322 -70
  209. package/frontend-vue/app/composables/translation/useWorkspaceNameCheck.ts +55 -0
  210. package/frontend-vue/app/composables/translation/useWorkspaceRoute.ts +129 -0
  211. package/frontend-vue/app/config/shortcuts-registry.ts +72 -0
  212. package/frontend-vue/app/types/lang.ts +130 -0
  213. package/frontend-vue/app/utils/boundedCache.ts +22 -0
  214. package/frontend-vue/app/utils/download.ts +16 -0
  215. package/frontend-vue/app/utils/keySaveErrors.ts +61 -0
  216. package/frontend-vue/app/utils/keySaves.ts +108 -0
  217. package/frontend-vue/app/utils/languages.ts +272 -0
  218. package/frontend-vue/app/utils/matrixExport.ts +47 -0
  219. package/frontend-vue/app/utils/queueDrafts.ts +115 -0
  220. package/frontend-vue/app/utils/queuePass.ts +145 -0
  221. package/frontend-vue/app/utils/queueView.ts +22 -0
  222. package/frontend-vue/app/utils/shortcuts.ts +75 -0
  223. package/frontend-vue/app/utils/translations.ts +756 -0
  224. package/frontend-vue/app/utils/workspaceBackup.ts +119 -0
  225. package/frontend-vue/app/utils/workspaces.ts +45 -0
  226. package/frontend-vue/dms.frontend.build.ts +5 -0
  227. package/frontend-vue/dms.frontend.ts +9 -20
  228. package/frontend-vue/i18n/locales/lang-en-GB.json +792 -69
  229. package/frontend-vue/i18n/locales/lang-fr-FR.json +792 -69
  230. package/frontend-vue/package.json +10 -5
  231. package/package.json +10 -8
  232. package/dist/utils/mutations.d.ts +0 -3
  233. package/dist/utils/mutations.js +0 -35
  234. package/dist/utils/mutations.js.map +0 -1
  235. package/frontend-vue/app/build/components/pages/lang/TranslationMatrix.vue +0 -284
  236. package/frontend-vue/app/components/LanguageAddModal.vue +0 -78
  237. package/frontend-vue/app/components/WorkspaceEndpoint.vue +0 -29
  238. package/frontend-vue/app/components/WorkspaceSelector.vue +0 -180
  239. package/frontend-vue/app/components/WorkspaceStatus.vue +0 -24
  240. package/frontend-vue/app/composables/translation/useLanguageCatalog.ts +0 -90
  241. package/frontend-vue/app/composables/translation/useLocaleMeta.ts +0 -18
  242. package/frontend-vue/app/composables/translation/useTranslationProgress.ts +0 -73
  243. package/frontend-vue/app/custom-pages/lang/overview.vue +0 -397
  244. package/frontend-vue/app/custom-pages/lang/translations.vue +0 -498
  245. package/frontend-vue/app/plugins/workspace-sidebar-widget.ts +0 -12
@@ -0,0 +1,106 @@
1
+ import { useActiveElement } from '@vueuse/core'
2
+ import { QUEUE_KEYS, shortcutName } from '../../utils/shortcuts'
3
+ import { isTypingTarget } from './useCellMoves'
4
+
5
+ /** What the queue's keys do. */
6
+ export interface QueueShortcutActions {
7
+ /** Whether a key is shown: without one, no key is bound. */
8
+ isActive: () => boolean
9
+ saveNext: () => void
10
+ save: () => void
11
+ skip: () => void
12
+ previous: () => void
13
+ }
14
+
15
+ /** The elements the keys depend on: the queue card and its text field. */
16
+ export interface QueueShortcutTargets {
17
+ root: () => HTMLElement | null | undefined
18
+ field: () => HTMLElement | null | undefined
19
+ }
20
+
21
+ interface ShortcutBinding {
22
+ usingInput?: boolean
23
+ handler: () => void
24
+ }
25
+
26
+ type ShortcutBindings = Record<string, ShortcutBinding>
27
+
28
+ const IN_FIELD = true
29
+
30
+ /** Whether the focus sits where the queue must not take keys: a dialog, a menu, another field. */
31
+ function isFocusElsewhere(
32
+ active: Element | null | undefined,
33
+ targets: QueueShortcutTargets,
34
+ ): boolean {
35
+ if (isFocusInsideOverlay(active)) return true
36
+ return isTypingTarget(active ?? null) && !targets.root()?.contains(active!)
37
+ }
38
+
39
+ function savingBindings(actions: QueueShortcutActions): ShortcutBindings {
40
+ return {
41
+ [shortcutName(QUEUE_KEYS.saveNext)]: {
42
+ usingInput: IN_FIELD,
43
+ handler: actions.saveNext,
44
+ },
45
+ [shortcutName(QUEUE_KEYS.save)]: {
46
+ usingInput: IN_FIELD,
47
+ handler: actions.save,
48
+ },
49
+ }
50
+ }
51
+
52
+ function movingBindings(
53
+ actions: QueueShortcutActions,
54
+ browse: (action: () => void) => () => void,
55
+ ): ShortcutBindings {
56
+ return {
57
+ [shortcutName(QUEUE_KEYS.skip)]: { handler: browse(actions.skip) },
58
+ [shortcutName(QUEUE_KEYS.previous)]: { handler: browse(actions.previous) },
59
+ }
60
+ }
61
+
62
+ function leavingBindings(field: HTMLElement): ShortcutBindings {
63
+ return {
64
+ [shortcutName(QUEUE_KEYS.leaveField)]: {
65
+ usingInput: IN_FIELD,
66
+ handler: () => field.blur(),
67
+ },
68
+ }
69
+ }
70
+
71
+ /**
72
+ * The keys of the translation queue, bound with `defineShortcuts` and listed
73
+ * in the DMS shortcuts registry: ⌘/Ctrl Enter saves and moves on, ⌘/Ctrl S
74
+ * saves, Escape leaves the text field, then S skips and P goes back. Typing
75
+ * never loses a key: S and P only act outside a text field, and nothing is
76
+ * bound while the focus is in a dialog, a menu or a field of another part of
77
+ * the page. A key reached with S or P leaves the focus where it was, so
78
+ * S and P can go on: `isBrowsing` says so while the queue moves.
79
+ */
80
+ export function useQueueShortcuts(
81
+ actions: QueueShortcutActions,
82
+ targets: QueueShortcutTargets,
83
+ ) {
84
+ const active = useActiveElement()
85
+ let isBrowsing = false
86
+ const browse = (action: () => void) => () => {
87
+ isBrowsing = true
88
+ action()
89
+ void nextTick(() => {
90
+ isBrowsing = false
91
+ })
92
+ }
93
+ const bindings = computed<ShortcutBindings>(() => {
94
+ if (!actions.isActive() || isFocusElsewhere(active.value, targets))
95
+ return {}
96
+ const field = targets.field()
97
+ const isInField = !!field && active.value === field
98
+ return {
99
+ ...savingBindings(actions),
100
+ ...movingBindings(actions, browse),
101
+ ...(isInField ? leavingBindings(field) : {}),
102
+ }
103
+ })
104
+ defineShortcuts(bindings)
105
+ return { isBrowsing: () => isBrowsing }
106
+ }
@@ -0,0 +1,99 @@
1
+ import type { QueueStep } from '../../utils/queuePass'
2
+
3
+ interface ToastContext {
4
+ t: ReturnType<typeof useI18n>['t']
5
+ toast: ReturnType<typeof useToast>
6
+ }
7
+
8
+ /** Long enough to copy a draft whose key was deleted elsewhere. */
9
+ const DELETED_DRAFT_MS = 15000
10
+
11
+ const STEP_TOASTS: Partial<Record<QueueStep, string>> = {
12
+ wrapped: 'dms_lang.queue.wrapped',
13
+ last: 'dms_lang.queue.last_key',
14
+ }
15
+
16
+ async function copyText({ t, toast }: ToastContext, value: string) {
17
+ try {
18
+ await navigator.clipboard.writeText(value)
19
+ toast.add({ title: t('dms_lang.queue.copied'), color: 'success' })
20
+ } catch {
21
+ toast.add({
22
+ title: t('dms_lang.queue.copy_failed'),
23
+ description: value,
24
+ color: 'warning',
25
+ icon: 'i-ph-copy',
26
+ duration: DELETED_DRAFT_MS,
27
+ })
28
+ }
29
+ }
30
+
31
+ function copyAction(context: ToastContext, draftText: string) {
32
+ return {
33
+ duration: DELETED_DRAFT_MS,
34
+ actions: [
35
+ {
36
+ label: context.t('dms_lang.queue.copy_draft'),
37
+ icon: 'i-ph-copy',
38
+ color: 'neutral' as const,
39
+ variant: 'outline' as const,
40
+ onClick: () => void copyText(context, draftText),
41
+ },
42
+ ],
43
+ }
44
+ }
45
+
46
+ function announceDeleted(context: ToastContext, key: string, draftText = '') {
47
+ const { t, toast } = context
48
+ const hasDraft = !!draftText.trim()
49
+ toast.add({
50
+ title: t('dms_lang.queue.deleted_title', { key }),
51
+ description: t(
52
+ hasDraft
53
+ ? 'dms_lang.queue.deleted_draft'
54
+ : 'dms_lang.queue.deleted_description',
55
+ ),
56
+ color: 'warning',
57
+ icon: 'i-ph-trash',
58
+ ...(hasDraft ? copyAction(context, draftText) : {}),
59
+ })
60
+ }
61
+
62
+ function showStep({ t, toast }: ToastContext, step: QueueStep | undefined) {
63
+ const title = step ? STEP_TOASTS[step] : undefined
64
+ if (!title) return
65
+ toast.add({ title: t(title), color: 'neutral', icon: 'i-ph-arrow-u-up-left' })
66
+ }
67
+
68
+ function warnBlocked({ t, toast }: ToastContext) {
69
+ toast.add({
70
+ title: t('dms_lang.queue.blocked'),
71
+ color: 'error',
72
+ icon: 'i-ph-warning-circle',
73
+ })
74
+ }
75
+
76
+ function warnConflict({ t, toast }: ToastContext, key: string) {
77
+ toast.add({
78
+ title: t('dms_lang.queue.conflict_title', { key }),
79
+ description: t('dms_lang.queue.conflict_description'),
80
+ color: 'warning',
81
+ icon: 'i-ph-warning',
82
+ })
83
+ }
84
+
85
+ /** The toasts of the translation queue: where it moved, a conflict, a deleted key. */
86
+ export function useQueueToasts() {
87
+ const context: ToastContext = { t: useI18n().t, toast: useToast() }
88
+ return {
89
+ /** Says the queue went back to the skipped keys, or stays on the last one. */
90
+ showStep: (step: QueueStep | undefined) => showStep(context, step),
91
+ warnConflict: (key: string) => warnConflict(context, key),
92
+ warnBlocked: () => warnBlocked(context),
93
+ notify: (title: string) =>
94
+ context.toast.add({ title, color: 'success', icon: 'i-ph-check' }),
95
+ /** Says a key left the queue because it was deleted elsewhere, offering its draft. */
96
+ announceDeleted: (key: string, draftText?: string) =>
97
+ announceDeleted(context, key, draftText),
98
+ }
99
+ }
@@ -0,0 +1,77 @@
1
+ <script setup lang="ts">
2
+ import { useWorkspaceFlatSync } from '../composables/translation/useWorkspaceFlat'
3
+ import { coverageTone } from '../utils/translations'
4
+
5
+ const { isLoaded } = useWorkspaceFlat()
6
+ useWorkspaceFlatSync()
7
+ const { isUnknown } = useWorkspaceContext()
8
+ const { formatCount } = useLangFormat()
9
+ const { namespace, namespaceProgress, exists, isBase } = useLanguageQueue()
10
+
11
+ function scope(target: string) {
12
+ namespace.value = namespace.value === target ? '' : target
13
+ }
14
+ </script>
15
+
16
+ <template>
17
+ <DmsCard
18
+ v-if="!isUnknown && ((exists && !isBase) || !isLoaded)"
19
+ :padded="false"
20
+ :title="$t('dms_lang.language_namespaces.title')"
21
+ >
22
+ <template v-if="namespace" #actions>
23
+ <UButton
24
+ size="xs"
25
+ color="neutral"
26
+ variant="ghost"
27
+ icon="i-ph-x"
28
+ :label="$t('dms_lang.language_namespaces.clear')"
29
+ @click="namespace = ''"
30
+ />
31
+ </template>
32
+ <div v-if="!isLoaded" class="space-y-2 p-4">
33
+ <USkeleton v-for="index in 5" :key="index" class="h-6 w-full" />
34
+ </div>
35
+ <ul v-else class="divide-default divide-y">
36
+ <li v-for="entry in namespaceProgress" :key="entry.namespace">
37
+ <button
38
+ type="button"
39
+ class="grid w-full grid-cols-[minmax(0,1fr)_5rem_3rem_3rem] items-center gap-3 px-4 py-2.5 text-left transition-colors"
40
+ :class="
41
+ namespace === entry.namespace
42
+ ? 'bg-primary/10'
43
+ : 'hover:bg-elevated/50'
44
+ "
45
+ :aria-pressed="namespace === entry.namespace"
46
+ @click="scope(entry.namespace)"
47
+ >
48
+ <span class="text-highlighted truncate font-mono text-xs">
49
+ {{ entry.namespace }}
50
+ </span>
51
+ <DmsMeter
52
+ :value="entry.coverage"
53
+ :max="100"
54
+ format="none"
55
+ size="xs"
56
+ :tone="coverageTone(entry.coverage)"
57
+ />
58
+ <span class="text-muted text-right font-mono text-xs">
59
+ {{ entry.coverage }}%
60
+ </span>
61
+ <span
62
+ class="text-right font-mono text-xs font-semibold"
63
+ :class="entry.missing ? 'text-warning' : 'text-dimmed'"
64
+ >
65
+ {{ formatCount(entry.missing) }}
66
+ </span>
67
+ </button>
68
+ </li>
69
+ </ul>
70
+ <template v-if="isLoaded" #footer>
71
+ <p class="text-dimmed flex items-center gap-1.5 text-xs">
72
+ <UIcon name="i-ph-info" class="size-3.5" />
73
+ {{ $t('dms_lang.language_namespaces.hint') }}
74
+ </p>
75
+ </template>
76
+ </DmsCard>
77
+ </template>
@@ -0,0 +1,222 @@
1
+ <script setup lang="ts">
2
+ import UButton from '@nuxt/ui/components/Button.vue'
3
+ import type { NamespaceMatrix, NamespaceRow } from '../types/lang'
4
+ import LocaleTile from '../build/components/LocaleTile.vue'
5
+ import { LANG_REALTIME_TOPIC } from '../composables/translation/useWorkspaceFlat'
6
+ import {
7
+ HIGH_COVERAGE,
8
+ MID_COVERAGE,
9
+ coveragePercent,
10
+ coverageTone,
11
+ } from '../utils/translations'
12
+
13
+ const MAX_NAMESPACES = 6
14
+ const MAX_LOCALES = 6
15
+
16
+ const HEAT_CLASSES: Record<'success' | 'warning' | 'error', string> = {
17
+ success: 'bg-success/15 text-success ring-success/25',
18
+ warning: 'bg-warning/15 text-warning ring-warning/25',
19
+ error: 'bg-error/15 text-error ring-error/25',
20
+ }
21
+
22
+ const { t } = useI18n()
23
+ const { data } = useChartFetch<NamespaceMatrix>({
24
+ fetchUrl: `${LANG_API}/namespaces?workspace={{query.workspace}}`,
25
+ realtimeTopic: LANG_REALTIME_TOPIC,
26
+ })
27
+ const { formatCount } = useLangFormat()
28
+ const links = useLangLinks()
29
+ const { isResolved, isUnknown } = useWorkspaceContext()
30
+ const { nameAmong } = useLocaleNames()
31
+ const isFirstRun = useFirstRun()
32
+
33
+ const isLoaded = computed(() => data.value !== null)
34
+ const targets = computed(() => data.value?.locales ?? [])
35
+ const locales = computed(() => targets.value.slice(0, MAX_LOCALES))
36
+ const hiddenLocales = computed(
37
+ () => targets.value.length - locales.value.length,
38
+ )
39
+
40
+ const allNamespaces = computed(() => data.value?.namespaces ?? [])
41
+ const namespaces = computed(() => allNamespaces.value.slice(0, MAX_NAMESPACES))
42
+ const hiddenNamespaces = computed(
43
+ () => allNamespaces.value.length - namespaces.value.length,
44
+ )
45
+
46
+ const neediest = computed(() => targets.value[0] ?? '')
47
+ const neediestMissing = computed(
48
+ () => data.value?.localeMissing[neediest.value] ?? 0,
49
+ )
50
+
51
+ function shownCoverage(entry: NamespaceRow, code: string): number {
52
+ return coveragePercent(entry.keys - (entry.missing[code] ?? 0), entry.keys)
53
+ }
54
+
55
+ function cellLink(entry: NamespaceRow, code: string): string {
56
+ if (!entry.missing[code]) {
57
+ return links.translations({ namespace: entry.namespace })
58
+ }
59
+ return links.translations({
60
+ namespace: entry.namespace,
61
+ missingIn: code,
62
+ filter: 'missing',
63
+ })
64
+ }
65
+
66
+ function cellLabel(entry: NamespaceRow, code: string): string {
67
+ const missing = entry.missing[code] ?? 0
68
+ const params = {
69
+ namespace: entry.namespace,
70
+ name: nameAmong(code, targets.value),
71
+ missing: formatCount(missing),
72
+ keys: formatCount(entry.keys),
73
+ }
74
+ if (!missing) return t('dms_lang.namespaces.cell_complete', params)
75
+ return t('dms_lang.namespaces.cell_missing', params, missing)
76
+ }
77
+
78
+ const gridTemplate = computed(
79
+ () =>
80
+ `minmax(6rem, 1fr) repeat(${locales.value.length}, minmax(2.5rem, 3rem))`,
81
+ )
82
+
83
+ usePageHeaderActions(() => [
84
+ isResolved.value && neediestMissing.value
85
+ ? h(UButton, {
86
+ label: t(
87
+ 'dms_lang.namespaces.translate_in',
88
+ {
89
+ count: formatCount(neediestMissing.value),
90
+ name: nameAmong(neediest.value, targets.value),
91
+ },
92
+ neediestMissing.value,
93
+ ),
94
+ icon: 'i-ph-translate',
95
+ to: links.translations({
96
+ filter: 'missing',
97
+ missingIn: neediest.value,
98
+ }),
99
+ })
100
+ : null,
101
+ ])
102
+ </script>
103
+
104
+ <template>
105
+ <DmsCard
106
+ v-if="!isUnknown && !isFirstRun"
107
+ :padded="false"
108
+ :title="$t('dms_lang.namespaces.title')"
109
+ >
110
+ <template #actions>
111
+ <UButton
112
+ size="xs"
113
+ color="neutral"
114
+ variant="ghost"
115
+ trailing-icon="i-ph-arrow-right"
116
+ :label="$t('dms_lang.namespaces.open_matrix')"
117
+ :to="links.translations()"
118
+ />
119
+ </template>
120
+
121
+ <div v-if="!isLoaded" class="space-y-2 p-4">
122
+ <USkeleton v-for="index in 4" :key="index" class="h-8 w-full" />
123
+ </div>
124
+
125
+ <DmsEmptyState
126
+ v-else-if="!locales.length || !namespaces.length"
127
+ size="sm"
128
+ :icon="namespaces.length ? 'i-ph-translate' : 'i-ph-key'"
129
+ :title="
130
+ namespaces.length
131
+ ? $t('dms_lang.namespaces.no_targets')
132
+ : $t('dms_lang.namespaces.no_keys')
133
+ "
134
+ />
135
+
136
+ <div v-else class="overflow-x-auto px-4 pt-3 pb-4">
137
+ <div
138
+ class="grid items-center gap-1.5"
139
+ :style="{ gridTemplateColumns: gridTemplate }"
140
+ >
141
+ <span />
142
+ <span
143
+ v-for="code in locales"
144
+ :key="code"
145
+ class="flex justify-center"
146
+ :title="`${nameAmong(code, targets)} · ${code}`"
147
+ >
148
+ <LocaleTile :code="code" :siblings="targets" size="sm" />
149
+ </span>
150
+ <template v-for="entry in namespaces" :key="entry.namespace">
151
+ <span class="flex min-w-0 items-baseline gap-1.5">
152
+ <span class="text-highlighted truncate font-mono text-xs">
153
+ {{ entry.namespace }}
154
+ </span>
155
+ <span class="text-dimmed font-mono text-[10.5px]">
156
+ {{ formatCount(entry.keys) }}
157
+ </span>
158
+ </span>
159
+ <ULink
160
+ v-for="code in locales"
161
+ :key="code"
162
+ :to="cellLink(entry, code)"
163
+ class="grid h-8 place-items-center rounded-md font-mono text-xs font-semibold ring-1 transition-opacity ring-inset hover:opacity-80"
164
+ :class="HEAT_CLASSES[coverageTone(shownCoverage(entry, code))]"
165
+ :title="cellLabel(entry, code)"
166
+ :aria-label="cellLabel(entry, code)"
167
+ >
168
+ {{ shownCoverage(entry, code) }}
169
+ </ULink>
170
+ </template>
171
+ </div>
172
+
173
+ <div
174
+ v-if="hiddenLocales || hiddenNamespaces"
175
+ class="text-muted mt-3 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs"
176
+ >
177
+ <span v-if="hiddenLocales">
178
+ {{
179
+ $t(
180
+ 'dms_lang.namespaces.more_locales',
181
+ { count: formatCount(hiddenLocales) },
182
+ hiddenLocales,
183
+ )
184
+ }}
185
+ </span>
186
+ <span v-if="hiddenNamespaces">
187
+ {{
188
+ $t(
189
+ 'dms_lang.namespaces.more_namespaces',
190
+ { count: formatCount(hiddenNamespaces) },
191
+ hiddenNamespaces,
192
+ )
193
+ }}
194
+ </span>
195
+ <ULink
196
+ :to="links.translations()"
197
+ class="text-primary ml-auto font-medium hover:underline"
198
+ >
199
+ {{ $t('dms_lang.namespaces.see_all') }}
200
+ </ULink>
201
+ </div>
202
+ </div>
203
+
204
+ <template v-if="isLoaded && namespaces.length && locales.length" #footer>
205
+ <div class="text-dimmed flex flex-wrap items-center gap-3 text-xs">
206
+ <span class="inline-flex items-center gap-1.5">
207
+ <span class="bg-success size-2 rounded-sm" />
208
+ ≥ {{ HIGH_COVERAGE }}%
209
+ </span>
210
+ <span class="inline-flex items-center gap-1.5">
211
+ <span class="bg-warning size-2 rounded-sm" />
212
+ {{ MID_COVERAGE }}–{{ HIGH_COVERAGE - 1 }}%
213
+ </span>
214
+ <span class="inline-flex items-center gap-1.5">
215
+ <span class="bg-error size-2 rounded-sm" />
216
+ &lt; {{ MID_COVERAGE }}%
217
+ </span>
218
+ <span class="ml-auto">{{ $t('dms_lang.namespaces.legend') }}</span>
219
+ </div>
220
+ </template>
221
+ </DmsCard>
222
+ </template>