|
| 1 | +<script setup lang="ts"> |
| 2 | +/** This component is not used at the moment, but we keep it not to lose code |
| 3 | + * produced to output report for translations per file. As we might need if |
| 4 | + * we split single translation files into multiple as it grows significantly |
| 5 | + */ |
| 6 | +const { locale } = useI18n() |
| 7 | +const { fetchStatus, localesMap } = useI18nStatus() |
| 8 | +
|
| 9 | +const localeEntries = computed(() => { |
| 10 | + const l = localesMap.value?.values() |
| 11 | + if (!l) return [] |
| 12 | + return [...mapFiles(l)] |
| 13 | +}) |
| 14 | +
|
| 15 | +function* mapFiles( |
| 16 | + map: MapIterator<I18nLocaleStatus>, |
| 17 | +): Generator<FileEntryStatus, undefined, void> { |
| 18 | + for (const entry of map) { |
| 19 | + yield { |
| 20 | + ...entry, |
| 21 | + lang: entry.lang, |
| 22 | + done: entry.completedKeys, |
| 23 | + missing: entry.missingKeys.length, |
| 24 | + file: entry.githubEditUrl.split('/').pop() ?? entry.lang, |
| 25 | + } |
| 26 | + } |
| 27 | +} |
| 28 | +</script> |
| 29 | + |
| 30 | +<template> |
| 31 | + <section class="prose prose-invert max-w-none space-y-8 pt-8"> |
| 32 | + <h2 id="by-file" tabindex="-1" class="text-xs text-fg-muted uppercase tracking-wider mb-4"> |
| 33 | + {{ $t('translation_status.by_file') }} |
| 34 | + </h2> |
| 35 | + <table class="w-full text-start border-collapse"> |
| 36 | + <thead class="border-b border-border text-start"> |
| 37 | + <tr> |
| 38 | + <th scope="col" class="py-2 px-2 font-medium text-fg-subtle text-sm"> |
| 39 | + {{ $t('translation_status.table.file') }} |
| 40 | + </th> |
| 41 | + <th scope="col" class="py-2 px-2 font-medium text-fg-subtle text-sm"> |
| 42 | + {{ $t('translation_status.table.status') }} |
| 43 | + </th> |
| 44 | + </tr> |
| 45 | + </thead> |
| 46 | + <tbody class="divide-y divide-border/50"> |
| 47 | + <template v-if="fetchStatus === 'error'"> |
| 48 | + <tr> |
| 49 | + <td colspan="2" class="py-4 px-2 text-center text-red-500"> |
| 50 | + {{ $t('translation_status.table.error') }} |
| 51 | + </td> |
| 52 | + </tr> |
| 53 | + </template> |
| 54 | + <template v-else-if="fetchStatus === 'pending' || fetchStatus === 'idle'"> |
| 55 | + <tr> |
| 56 | + <td colspan="2" class="py-4 px-2 text-center text-fg-muted"> |
| 57 | + <SkeletonBlock class="h-10 w-full mb-4" /> |
| 58 | + <SkeletonBlock class="h-10 w-full mb-4" /> |
| 59 | + <SkeletonBlock class="h-10 w-full mb-4" /> |
| 60 | + </td> |
| 61 | + </tr> |
| 62 | + </template> |
| 63 | + <template v-else-if="!localeEntries || localeEntries.length === 0"> |
| 64 | + <tr> |
| 65 | + <td colspan="2" class="py-4 px-2 text-center text-fg-muted"> |
| 66 | + {{ $t('translation_status.table.empty') }} |
| 67 | + </td> |
| 68 | + </tr> |
| 69 | + </template> |
| 70 | + <template v-else> |
| 71 | + <tr> |
| 72 | + <td class="py-3 px-2 font-mono text-sm"> |
| 73 | + <LinkBase to="https://github.com/npmx-dev/npmx.dev/blob/main/i18n/locales/en.json"> |
| 74 | + <i18n-t |
| 75 | + keypath="translation_status.table.file_link" |
| 76 | + scope="global" |
| 77 | + tag="span" |
| 78 | + :class="locale === 'en-US' ? 'font-bold' : undefined" |
| 79 | + > |
| 80 | + <template #file>en.json</template> |
| 81 | + <template #lang>en-US</template> |
| 82 | + </i18n-t> |
| 83 | + </LinkBase> |
| 84 | + </td> |
| 85 | + <td class="py-3 px-2"> |
| 86 | + <div class="flex items-center gap-2"> |
| 87 | + <progress |
| 88 | + class="done w-24 h-1.5 rounded-full overflow-hidden" |
| 89 | + max="100" |
| 90 | + value="100" |
| 91 | + ></progress> |
| 92 | + <span class="text-xs font-mono text-fg-muted"> |
| 93 | + {{ $n(1, 'percentage') }} |
| 94 | + </span> |
| 95 | + </div> |
| 96 | + </td> |
| 97 | + </tr> |
| 98 | + <tr v-for="file in localeEntries" :key="file.lang"> |
| 99 | + <td class="py-3 px-2 font-mono text-sm"> |
| 100 | + <LinkBase :to="file.githubEditUrl"> |
| 101 | + <i18n-t |
| 102 | + keypath="translation_status.table.file_link" |
| 103 | + scope="global" |
| 104 | + tag="span" |
| 105 | + :class="locale === file.lang ? 'font-bold' : undefined" |
| 106 | + > |
| 107 | + <template #file> |
| 108 | + {{ file.file }} |
| 109 | + </template> |
| 110 | + <template #lang> |
| 111 | + {{ file.lang }} |
| 112 | + </template> |
| 113 | + </i18n-t> |
| 114 | + </LinkBase> |
| 115 | + </td> |
| 116 | + <td class="py-3 px-2"> |
| 117 | + <div class="flex items-center gap-2"> |
| 118 | + <ProgressBar |
| 119 | + :val="file.percentComplete" |
| 120 | + :label="$t('translation_status.progress_label', { locale: file.label })" |
| 121 | + /> |
| 122 | + <span class="text-xs font-mono text-fg-muted">{{ |
| 123 | + $n(file.percentComplete / 100, 'percentage') |
| 124 | + }}</span> |
| 125 | + </div> |
| 126 | + </td> |
| 127 | + </tr> |
| 128 | + </template> |
| 129 | + </tbody> |
| 130 | + </table> |
| 131 | + </section> |
| 132 | +</template> |
0 commit comments