Skip to content

Commit 5d19137

Browse files
committed
the view_on translations for the git providers are now in the comments to satisfy i18n report
1 parent 3d8997b commit 5d19137

1 file changed

Lines changed: 22 additions & 23 deletions

File tree

app/composables/useViewOnGitProvider.ts

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,31 @@
44
export function useViewOnGitProvider(
55
provider: MaybeRefOrGetter<ProviderId | (string & {}) | null | undefined>,
66
) {
7-
const { t } = useI18n()
7+
const { t, te } = useI18n()
88
return computed(() => {
99
const uProvider = toValue(provider)
10-
// using this switch instead of `view_on.${provider}` to prevent missing future translations
11-
switch (uProvider) {
12-
case 'github':
13-
return t('common.view_on.github')
14-
case 'gitlab':
15-
return t('common.view_on.gitlab')
16-
case 'bitbucket':
17-
return t('common.view_on.bitbucket')
18-
case 'codeberg':
19-
return t('common.view_on.codeberg')
20-
case 'forgejo':
21-
return t('common.view_on.forgejo')
22-
case 'gitea':
23-
return t('common.view_on.gitea')
24-
case 'gitee':
25-
return t('common.view_on.gitee')
26-
case 'radicle':
27-
return t('common.view_on.radicle')
28-
case 'sourcehut':
29-
return t('common.view_on.sourcehut')
30-
case 'tangled':
31-
return t('common.view_on.tangled')
10+
if (!uProvider) {
11+
return t('common.view_on.git_repo')
3212
}
13+
const key = `common.view_on.${uProvider}`
14+
if (te(key)) {
15+
return t(key)
16+
}
17+
// oxlint-disable-next-line no-console
18+
console.warn(`"common.view_on.${uProvider}" translation doesn't exist`)
3319
return t('common.view_on.git_repo')
3420
})
3521
}
22+
23+
/* for i18n report, translations that are currently present:
24+
t('common.view_on.github')
25+
t('common.view_on.gitlab')
26+
t('common.view_on.bitbucket')
27+
t('common.view_on.codeberg')
28+
t('common.view_on.forgejo')
29+
t('common.view_on.gitea')
30+
t('common.view_on.gitee')
31+
t('common.view_on.radicle')
32+
t('common.view_on.sourcehut')
33+
t('common.view_on.tangled')
34+
*/

0 commit comments

Comments
 (0)