|
4 | 4 | export function useViewOnGitProvider( |
5 | 5 | provider: MaybeRefOrGetter<ProviderId | (string & {}) | null | undefined>, |
6 | 6 | ) { |
7 | | - const { t, te } = useI18n() |
| 7 | + const { t } = useI18n() |
8 | 8 | return computed(() => { |
9 | 9 | const uProvider = toValue(provider) |
10 | 10 | if (!uProvider) { |
11 | 11 | return t('common.view_on.git_repo') |
12 | 12 | } |
13 | | - const key = `common.view_on.${uProvider}` |
14 | | - if (te(key)) { |
15 | | - return t(key) |
| 13 | + switch (uProvider) { |
| 14 | + case 'github': |
| 15 | + return t('common.view_on.github') |
| 16 | + case 'gitlab': |
| 17 | + return t('common.view_on.gitlab') |
| 18 | + case 'bitbucket': |
| 19 | + return t('common.view_on.bitbucket') |
| 20 | + case 'codeberg': |
| 21 | + return t('common.view_on.codeberg') |
| 22 | + case 'forgejo': |
| 23 | + return t('common.view_on.forgejo') |
| 24 | + case 'gitea': |
| 25 | + return t('common.view_on.gitea') |
| 26 | + case 'gitee': |
| 27 | + return t('common.view_on.gitee') |
| 28 | + case 'radicle': |
| 29 | + return t('common.view_on.radicle') |
| 30 | + case 'sourcehut': |
| 31 | + return t('common.view_on.sourcehut') |
| 32 | + case 'git': |
| 33 | + return t('common.view_on.git_repo') |
| 34 | + } |
| 35 | + |
| 36 | + if (import.meta.dev) { |
| 37 | + // oxlint-disable-next-line no-console |
| 38 | + console.warn(`missing '${uProvider}' provider, add it to shared/utils/git-providers.ts!`) |
16 | 39 | } |
17 | | - // oxlint-disable-next-line no-console |
18 | | - console.warn(`"common.view_on.${uProvider}" translation doesn't exist`) |
19 | 40 | return t('common.view_on.git_repo') |
20 | 41 | }) |
21 | 42 | } |
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