Skip to content

Commit 04f3ab9

Browse files
WilcoSpuserquin
andauthored
feat(i18n): localise translations for other git providers (#1962)
Co-authored-by: userquin <userquin@gmail.com>
1 parent bbb937b commit 04f3ab9

32 files changed

+237
-89
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* Return the text "see on {git provider}" based on the given provider
3+
*/
4+
export function useViewOnGitProvider(
5+
provider: MaybeRefOrGetter<ProviderId | (string & {}) | null | undefined>,
6+
) {
7+
const { t } = useI18n()
8+
return computed(() => {
9+
const uProvider = toValue(provider)
10+
if (!uProvider) {
11+
return t('common.view_on.git_repo')
12+
}
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 'gitea':
21+
return t('common.view_on.gitea')
22+
case 'forgejo':
23+
return t('common.view_on.forgejo')
24+
case 'codeberg':
25+
return t('common.view_on.codeberg')
26+
case 'sourcehut':
27+
return t('common.view_on.sourcehut')
28+
case 'gitee':
29+
return t('common.view_on.gitee')
30+
case 'tangled':
31+
return t('common.view_on.tangled')
32+
case 'radicle':
33+
return t('common.view_on.radicle')
34+
case 'git':
35+
return t('common.view_on.git_repo')
36+
}
37+
38+
if (import.meta.dev) {
39+
// oxlint-disable-next-line no-console
40+
console.warn(`missing '${uProvider}' provider, add it to shared/utils/git-providers.ts!`)
41+
}
42+
return t('common.view_on.git_repo')
43+
})
44+
}

app/pages/org/[org].vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ defineOgImageComponent('Default', {
175175
target="_blank"
176176
rel="noopener noreferrer"
177177
class="link-subtle font-mono text-sm inline-flex items-center gap-1.5"
178-
:title="$t('common.view_on_npm')"
178+
:title="$t('common.view_on.npm')"
179179
>
180180
<span class="i-simple-icons:npm w-4 h-4" aria-hidden="true" />
181181
npm

app/pages/package/[[org]]/[name].vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { useModal } from '~/composables/useModal'
2121
import { useAtproto } from '~/composables/atproto/useAtproto'
2222
import { togglePackageLike } from '~/utils/atproto/likes'
2323
import { useInstallSizeDiff } from '~/composables/useInstallSizeDiff'
24+
import { useViewOnGitProvider } from '~/composables/useViewOnGitProvider'
2425
import type { RouteLocationRaw } from 'vue-router'
2526
2627
defineOgImageComponent('Package', {
@@ -503,6 +504,8 @@ const repoProviderIcon = computed((): IconClass => {
503504
return PROVIDER_ICONS[provider] ?? 'i-lucide:code'
504505
})
505506
507+
const viewOnGitProvider = useViewOnGitProvider(() => repoRef.value?.provider)
508+
506509
const homepageUrl = computed(() => {
507510
const homepage = displayVersion.value?.homepage
508511
if (!homepage) return null
@@ -1003,7 +1006,7 @@ const showSkeleton = shallowRef(false)
10031006
<li>
10041007
<LinkBase
10051008
:to="`https://www.npmjs.com/package/${pkg.name}`"
1006-
:title="$t('common.view_on_npm')"
1009+
:title="$t('common.view_on.npm')"
10071010
classicon="i-simple-icons:npm"
10081011
>
10091012
npm
@@ -1448,7 +1451,8 @@ const showSkeleton = shallowRef(false)
14481451
target="_blank"
14491452
rel="noopener noreferrer"
14501453
class="link text-fg underline underline-offset-4 decoration-fg-subtle hover:(decoration-fg text-fg) transition-colors duration-200"
1451-
>{{ $t('package.readme.view_on_github') }}</a
1454+
>
1455+
{{ viewOnGitProvider }}</a
14521456
>
14531457
</p>
14541458

app/pages/~[username]/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ defineOgImageComponent('Default', {
156156
target="_blank"
157157
rel="noopener noreferrer"
158158
class="link-subtle font-mono text-sm inline-flex items-center gap-1.5"
159-
:title="$t('common.view_on_npm')"
159+
:title="$t('common.view_on.npm')"
160160
>
161161
<span class="i-simple-icons:npm w-4 h-4" aria-hidden="true" />
162162
npm

i18n/locales/ar.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,18 @@
132132
"skip_link": "تخطي إلى المحتوى الرئيسي",
133133
"warnings": "تحذيرات:",
134134
"go_back_home": "العودة إلى الصفحة الرئيسية",
135-
"view_on_npm": "عرض على npm",
136135
"per_week": "/ أسبوع",
137136
"vanity_downloads_hint": "رقم زخرفي: لا توجد حزم معروضة | رقم زخرفي: للحزمة المعروضة | رقم زخرفي: للحزمتين المعروضتين | رقم زخرفي: مجموع {count} من الحزم المعروضة | رقم زخرفي: مجموع {count} من الحزم المعروضة | رقم زخرفي: مجموع {count} من الحزم المعروضة",
138137
"sort": {
139138
"name": "الاسم",
140139
"role": "الدور",
141140
"members": "الأعضاء"
142141
},
143-
"scroll_to_top": "التمرير إلى الأعلى"
142+
"scroll_to_top": "التمرير إلى الأعلى",
143+
"view_on": {
144+
"npm": "عرض على npm",
145+
"github": "عرض على GitHub"
146+
}
144147
},
145148
"package": {
146149
"not_found": "لم يتم العثور على الحزمة",
@@ -238,7 +241,6 @@
238241
"readme": {
239242
"title": "README (إقرأني)",
240243
"no_readme": "لا يتوفر README.",
241-
"view_on_github": "عرض على GitHub",
242244
"toc_title": "جدول المحتويات",
243245
"callout": {
244246
"note": "ملاحظة",

i18n/locales/az-AZ.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,18 @@
177177
"skip_link": "Əsas məzmuna keç",
178178
"warnings": "Xəbərdarlıqlar:",
179179
"go_back_home": "Ana səhifəyə qayıt",
180-
"view_on_npm": "npm-də bax",
181180
"per_week": "/ həftə",
182181
"vanity_downloads_hint": "Göstərici: paket göstərilmir | Göstərici: göstərilən paket üçün | Göstərici: {count} göstərilən paketin cəmi",
183182
"sort": {
184183
"name": "ad",
185184
"role": "rol",
186185
"members": "üzvlər"
187186
},
188-
"scroll_to_top": "Yuxarı qayıt"
187+
"scroll_to_top": "Yuxarı qayıt",
188+
"view_on": {
189+
"npm": "npm-də bax",
190+
"github": "GitHub-da bax"
191+
}
189192
},
190193
"package": {
191194
"not_found": "Paket Tapılmadı",
@@ -290,7 +293,6 @@
290293
"readme": {
291294
"title": "Readme",
292295
"no_readme": "README mövcud deyil.",
293-
"view_on_github": "GitHub-da bax",
294296
"toc_title": "Məzmun",
295297
"callout": {
296298
"note": "Qeyd",

i18n/locales/bg-BG.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@
136136
"skip_link": "Преминаване към основното съдържание",
137137
"warnings": "Предупреждения:",
138138
"go_back_home": "Назад към начална страница",
139-
"view_on_npm": "преглед в npm",
140139
"per_week": "/ седмица",
141140
"vanity_downloads_hint": "Брой за показ: няма показани пакети | Брой за показ: за показания пакет | Брой за показ: Сума от {count} показани пакета",
142141
"sort": {
@@ -148,7 +147,11 @@
148147
"cancel": "Отказ",
149148
"save": "Запазване",
150149
"edit": "Редактиране",
151-
"error": "Грешка"
150+
"error": "Грешка",
151+
"view_on": {
152+
"npm": "преглед в npm",
153+
"github": "Преглед в GitHub"
154+
}
152155
},
153156
"profile": {
154157
"display_name": "Показвано име",
@@ -270,7 +273,6 @@
270273
"readme": {
271274
"title": "Readme",
272275
"no_readme": "Няма наличен README.",
273-
"view_on_github": "Преглед в GitHub",
274276
"toc_title": "Съдържание",
275277
"callout": {
276278
"note": "Бележка",

i18n/locales/bn-IN.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,18 @@
9999
"skip_link": "মুখ্য কন্টেন্টে যান",
100100
"warnings": "সতর্কতা:",
101101
"go_back_home": "হোমে ফিরে যান",
102-
"view_on_npm": "npm এ দেখুন",
103102
"per_week": "/ সপ্তাহ",
104103
"vanity_downloads_hint": "ভ্যানিটি নম্বর: কোন প্যাকেজ প্রদর্শিত হয়নি | ভ্যানিটি নম্বর: প্রদর্শিত প্যাকেজের জন্য | ভ্যানিটি নম্বর: {count} প্রদর্শিত প্যাকেজের মোট",
105104
"sort": {
106105
"name": "নাম",
107106
"role": "ভূমিকা",
108107
"members": "সদস্য"
109108
},
110-
"scroll_to_top": "উপরে স্ক্রল করুন"
109+
"scroll_to_top": "উপরে স্ক্রল করুন",
110+
"view_on": {
111+
"npm": "npm এ দেখুন",
112+
"github": "GitHub এ দেখুন"
113+
}
111114
},
112115
"package": {
113116
"not_found": "প্যাকেজ পাওয়া যায়নি",
@@ -194,7 +197,6 @@
194197
"readme": {
195198
"title": "রিডমি",
196199
"no_readme": "README উপলব্ধ নেই।",
197-
"view_on_github": "GitHub এ দেখুন",
198200
"callout": {}
199201
},
200202
"provenance_section": {},

i18n/locales/cs-CZ.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@
178178
"skip_link": "Přejít na hlavní obsah",
179179
"warnings": "Varování:",
180180
"go_back_home": "Zpět na začátek",
181-
"view_on_npm": "Zobrazit na npm",
182181
"per_week": "/ týden",
183182
"vanity_downloads_hint": "Pro zobrazený balíček | Součet pro {count} zobrazené balíčky | Součet pro {count} zobrazených balíčků",
184183
"sort": {
@@ -190,7 +189,11 @@
190189
"cancel": "Zrušit",
191190
"save": "Uložit",
192191
"edit": "Upravit",
193-
"error": "Chyba"
192+
"error": "Chyba",
193+
"view_on": {
194+
"npm": "Zobrazit na npm",
195+
"github": "Zobrazit na GitHubu"
196+
}
194197
},
195198
"profile": {
196199
"display_name": "Zobrazované jméno",
@@ -312,7 +315,6 @@
312315
"readme": {
313316
"title": "ČTI MĚ",
314317
"no_readme": "Žádné ČTI MĚ NENÍ k dispozici.",
315-
"view_on_github": "Zobrazit na GitHubu",
316318
"toc_title": "Obsah",
317319
"callout": {
318320
"note": "Poznámka",

i18n/locales/de-DE.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@
146146
"skip_link": "Zum Hauptinhalt springen",
147147
"warnings": "Warnungen:",
148148
"go_back_home": "Zur Startseite",
149-
"view_on_npm": "Auf npm ansehen",
150149
"per_week": "/ Woche",
151150
"vanity_downloads_hint": "Vanity-Zahl: keine Pakete angezeigt | Vanity-Zahl: für das angezeigte Paket | Vanity-Zahl: Summe von {count} angezeigten Paketen",
152151
"sort": {
@@ -158,7 +157,11 @@
158157
"cancel": "Abbrechen",
159158
"save": "Speichern",
160159
"edit": "Bearbeiten",
161-
"error": "Fehler"
160+
"error": "Fehler",
161+
"view_on": {
162+
"npm": "Auf npm ansehen",
163+
"github": "Auf GitHub ansehen"
164+
}
162165
},
163166
"error": {
164167
"401": "Nicht autorisiert",
@@ -312,7 +315,6 @@
312315
"readme": {
313316
"title": "Readme",
314317
"no_readme": "Keine README verfügbar.",
315-
"view_on_github": "Auf GitHub ansehen",
316318
"toc_title": "Gliederung",
317319
"callout": {
318320
"note": "Notiz",

0 commit comments

Comments
 (0)