Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions app/composables/useViewOnGitProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* Return the text "see on {git provider}" based on the given provider
*/
export function useViewOnGitProvider(
provider: MaybeRefOrGetter<ProviderId | (string & {}) | null | undefined>,
) {
const { t } = useI18n()
return computed(() => {
const uProvider = toValue(provider)
if (!uProvider) {
return t('common.view_on.git_repo')
}
switch (uProvider) {
case 'github':
return t('common.view_on.github')
case 'gitlab':
return t('common.view_on.gitlab')
case 'bitbucket':
return t('common.view_on.bitbucket')
case 'gitea':
return t('common.view_on.gitea')
case 'forgejo':
return t('common.view_on.forgejo')
case 'codeberg':
return t('common.view_on.codeberg')
case 'sourcehut':
return t('common.view_on.sourcehut')
case 'gitee':
return t('common.view_on.gitee')
case 'tangled':
return t('common.view_on.tangled')
case 'radicle':
return t('common.view_on.radicle')
case 'git':
return t('common.view_on.git_repo')
}

if (import.meta.dev) {
// oxlint-disable-next-line no-console
console.warn(`missing '${uProvider}' provider, add it to shared/utils/git-providers.ts!`)
}
return t('common.view_on.git_repo')
Copy link
Member

@userquin userquin Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have string & {}, can we use te fromuseI18n to check if the key exists? Otherwise return gihub

Copy link
Member

@userquin userquin Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return uProvider && te(`common.view_on.${uProvider}`) ? t(`common.view_on.${uProvider}`) : t('common.view_on.git_repo')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll change it to use te but I do think it's best to return "Git repository" instead of Github as it is closer to the truth than returning github by default

Copy link
Member

@userquin userquin Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the case to the swtich (without default), then add console.warn (add eslint rule to ignore that console.warn) and return the value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've figured out that the keys can also be referenced in comments, that way 'te' can still be used

})
}
2 changes: 1 addition & 1 deletion app/pages/org/[org].vue
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ defineOgImageComponent('Default', {
target="_blank"
rel="noopener noreferrer"
class="link-subtle font-mono text-sm inline-flex items-center gap-1.5"
:title="$t('common.view_on_npm')"
:title="$t('common.view_on.npm')"
>
<span class="i-simple-icons:npm w-4 h-4" aria-hidden="true" />
npm
Expand Down
8 changes: 6 additions & 2 deletions app/pages/package/[[org]]/[name].vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { useModal } from '~/composables/useModal'
import { useAtproto } from '~/composables/atproto/useAtproto'
import { togglePackageLike } from '~/utils/atproto/likes'
import { useInstallSizeDiff } from '~/composables/useInstallSizeDiff'
import { useViewOnGitProvider } from '~/composables/useViewOnGitProvider'
import type { RouteLocationRaw } from 'vue-router'

defineOgImageComponent('Package', {
Expand Down Expand Up @@ -503,6 +504,8 @@ const repoProviderIcon = computed((): IconClass => {
return PROVIDER_ICONS[provider] ?? 'i-lucide:code'
})

const viewOnGitProvider = useViewOnGitProvider(() => repoRef.value?.provider)

const homepageUrl = computed(() => {
const homepage = displayVersion.value?.homepage
if (!homepage) return null
Expand Down Expand Up @@ -1007,7 +1010,7 @@ const showSkeleton = shallowRef(false)
<li>
<LinkBase
:to="`https://www.npmjs.com/package/${pkg.name}`"
:title="$t('common.view_on_npm')"
:title="$t('common.view_on.npm')"
classicon="i-simple-icons:npm"
>
npm
Expand Down Expand Up @@ -1452,7 +1455,8 @@ const showSkeleton = shallowRef(false)
target="_blank"
rel="noopener noreferrer"
class="link text-fg underline underline-offset-4 decoration-fg-subtle hover:(decoration-fg text-fg) transition-colors duration-200"
>{{ $t('package.readme.view_on_github') }}</a
>
{{ viewOnGitProvider }}</a
>
</p>

Expand Down
2 changes: 1 addition & 1 deletion app/pages/~[username]/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ defineOgImageComponent('Default', {
target="_blank"
rel="noopener noreferrer"
class="link-subtle font-mono text-sm inline-flex items-center gap-1.5"
:title="$t('common.view_on_npm')"
:title="$t('common.view_on.npm')"
>
<span class="i-simple-icons:npm w-4 h-4" aria-hidden="true" />
npm
Expand Down
8 changes: 5 additions & 3 deletions i18n/locales/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,18 @@
"skip_link": "تخطي إلى المحتوى الرئيسي",
"warnings": "تحذيرات:",
"go_back_home": "العودة إلى الصفحة الرئيسية",
"view_on_npm": "عرض على npm",
"per_week": "/ أسبوع",
"vanity_downloads_hint": "رقم زخرفي: لا توجد حزم معروضة | رقم زخرفي: للحزمة المعروضة | رقم زخرفي: للحزمتين المعروضتين | رقم زخرفي: مجموع {count} من الحزم المعروضة | رقم زخرفي: مجموع {count} من الحزم المعروضة | رقم زخرفي: مجموع {count} من الحزم المعروضة",
"sort": {
"name": "الاسم",
"role": "الدور",
"members": "الأعضاء"
},
"scroll_to_top": "التمرير إلى الأعلى"
"scroll_to_top": "التمرير إلى الأعلى",
"view_on": {
"npm": "عرض على npm",
"github": "عرض على GitHub"
}
},
"package": {
"not_found": "لم يتم العثور على الحزمة",
Expand Down Expand Up @@ -238,7 +241,6 @@
"readme": {
"title": "README (إقرأني)",
"no_readme": "لا يتوفر README.",
"view_on_github": "عرض على GitHub",
"toc_title": "جدول المحتويات",
"callout": {
"note": "ملاحظة",
Expand Down
8 changes: 5 additions & 3 deletions i18n/locales/az-AZ.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,18 @@
"skip_link": "Əsas məzmuna keç",
"warnings": "Xəbərdarlıqlar:",
"go_back_home": "Ana səhifəyə qayıt",
"view_on_npm": "npm-də bax",
"per_week": "/ həftə",
"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",
"sort": {
"name": "ad",
"role": "rol",
"members": "üzvlər"
},
"scroll_to_top": "Yuxarı qayıt"
"scroll_to_top": "Yuxarı qayıt",
"view_on": {
"npm": "npm-də bax",
"github": "GitHub-da bax"
}
},
"package": {
"not_found": "Paket Tapılmadı",
Expand Down Expand Up @@ -290,7 +293,6 @@
"readme": {
"title": "Readme",
"no_readme": "README mövcud deyil.",
"view_on_github": "GitHub-da bax",
"toc_title": "Məzmun",
"callout": {
"note": "Qeyd",
Expand Down
8 changes: 5 additions & 3 deletions i18n/locales/bg-BG.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@
"skip_link": "Преминаване към основното съдържание",
"warnings": "Предупреждения:",
"go_back_home": "Назад към начална страница",
"view_on_npm": "преглед в npm",
"per_week": "/ седмица",
"vanity_downloads_hint": "Брой за показ: няма показани пакети | Брой за показ: за показания пакет | Брой за показ: Сума от {count} показани пакета",
"sort": {
Expand All @@ -148,7 +147,11 @@
"cancel": "Отказ",
"save": "Запазване",
"edit": "Редактиране",
"error": "Грешка"
"error": "Грешка",
"view_on": {
"npm": "преглед в npm",
"github": "Преглед в GitHub"
}
},
"profile": {
"display_name": "Показвано име",
Expand Down Expand Up @@ -270,7 +273,6 @@
"readme": {
"title": "Readme",
"no_readme": "Няма наличен README.",
"view_on_github": "Преглед в GitHub",
"toc_title": "Съдържание",
"callout": {
"note": "Бележка",
Expand Down
8 changes: 5 additions & 3 deletions i18n/locales/bn-IN.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,18 @@
"skip_link": "মুখ্য কন্টেন্টে যান",
"warnings": "সতর্কতা:",
"go_back_home": "হোমে ফিরে যান",
"view_on_npm": "npm এ দেখুন",
"per_week": "/ সপ্তাহ",
"vanity_downloads_hint": "ভ্যানিটি নম্বর: কোন প্যাকেজ প্রদর্শিত হয়নি | ভ্যানিটি নম্বর: প্রদর্শিত প্যাকেজের জন্য | ভ্যানিটি নম্বর: {count} প্রদর্শিত প্যাকেজের মোট",
"sort": {
"name": "নাম",
"role": "ভূমিকা",
"members": "সদস্য"
},
"scroll_to_top": "উপরে স্ক্রল করুন"
"scroll_to_top": "উপরে স্ক্রল করুন",
"view_on": {
"npm": "npm এ দেখুন",
"github": "GitHub এ দেখুন"
}
},
"package": {
"not_found": "প্যাকেজ পাওয়া যায়নি",
Expand Down Expand Up @@ -194,7 +197,6 @@
"readme": {
"title": "রিডমি",
"no_readme": "README উপলব্ধ নেই।",
"view_on_github": "GitHub এ দেখুন",
"callout": {}
},
"provenance_section": {},
Expand Down
8 changes: 5 additions & 3 deletions i18n/locales/cs-CZ.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@
"skip_link": "Přejít na hlavní obsah",
"warnings": "Varování:",
"go_back_home": "Zpět na začátek",
"view_on_npm": "Zobrazit na npm",
"per_week": "/ týden",
"vanity_downloads_hint": "Pro zobrazený balíček | Součet pro {count} zobrazené balíčky | Součet pro {count} zobrazených balíčků",
"sort": {
Expand All @@ -190,7 +189,11 @@
"cancel": "Zrušit",
"save": "Uložit",
"edit": "Upravit",
"error": "Chyba"
"error": "Chyba",
"view_on": {
"npm": "Zobrazit na npm",
"github": "Zobrazit na GitHubu"
}
},
"profile": {
"display_name": "Zobrazované jméno",
Expand Down Expand Up @@ -312,7 +315,6 @@
"readme": {
"title": "ČTI MĚ",
"no_readme": "Žádné ČTI MĚ NENÍ k dispozici.",
"view_on_github": "Zobrazit na GitHubu",
"toc_title": "Obsah",
"callout": {
"note": "Poznámka",
Expand Down
8 changes: 5 additions & 3 deletions i18n/locales/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@
"skip_link": "Zum Hauptinhalt springen",
"warnings": "Warnungen:",
"go_back_home": "Zur Startseite",
"view_on_npm": "Auf npm ansehen",
"per_week": "/ Woche",
"vanity_downloads_hint": "Vanity-Zahl: keine Pakete angezeigt | Vanity-Zahl: für das angezeigte Paket | Vanity-Zahl: Summe von {count} angezeigten Paketen",
"sort": {
Expand All @@ -158,7 +157,11 @@
"cancel": "Abbrechen",
"save": "Speichern",
"edit": "Bearbeiten",
"error": "Fehler"
"error": "Fehler",
"view_on": {
"npm": "Auf npm ansehen",
"github": "Auf GitHub ansehen"
}
},
"error": {
"401": "Nicht autorisiert",
Expand Down Expand Up @@ -312,7 +315,6 @@
"readme": {
"title": "Readme",
"no_readme": "Keine README verfügbar.",
"view_on_github": "Auf GitHub ansehen",
"toc_title": "Gliederung",
"callout": {
"note": "Notiz",
Expand Down
18 changes: 15 additions & 3 deletions i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@
"skip_link": "Skip to main content",
"warnings": "Warnings:",
"go_back_home": "Go back home",
"view_on_npm": "view on npm",
"per_week": "/ week",
"vanity_downloads_hint": "Vanity number: no packages displayed | Vanity number: for the displayed package | Vanity number: Sum of {count} displayed packages",
"sort": {
Expand All @@ -190,7 +189,21 @@
"cancel": "Cancel",
"save": "Save",
"edit": "Edit",
"error": "Error"
"error": "Error",
"view_on": {
"npm": "view on npm",
Copy link
Contributor

@coderabbitai coderabbitai bot Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Inconsistent capitalisation: "view" should be "View".

All other entries in view_on start with uppercase "View on …", but the npm entry uses lowercase "view on npm". For UI consistency, capitalise "View" while keeping "npm" lowercase per its branding.

✏️ Proposed fix
-      "npm": "view on npm",
+      "npm": "View on npm",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"npm": "view on npm",
"npm": "View on npm",

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's "view" instead of "View" because it was originally like that, the same for github it's "View" because before moving the translation it also was with "View"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WilcoSp, understood — the casing is intentional, preserving the original values from before the keys were moved. Thanks for the context!


✏️ Learnings added
Learnt from: WilcoSp
Repo: npmx-dev/npmx.dev PR: 1962
File: i18n/locales/en.json:194-194
Timestamp: 2026-03-06T16:08:13.589Z
Learning: In `i18n/locales/en.json`, the `common.view_on.npm` entry intentionally uses lowercase "view on npm" (matching its original casing from `common.view_on_npm`), while `common.view_on.github` uses "View on GitHub" (uppercase, matching its original casing from `package.readme.view_on_github`). The inconsistency is deliberate and should not be flagged in future reviews.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


🧠 Learnings used
Learnt from: serhalp
Repo: npmx-dev/npmx.dev PR: 1183
File: lunaria/files/uk-UA.json:305-318
Timestamp: 2026-02-08T18:44:10.538Z
Learning: In the npmx.dev project, new or changed entries in i18n translation files (locale JSON files) may be omitted from non-English languages. Translations are not completed in-band in the same PR and are tracked elsewhere. It is acceptable for non-English locale files to be missing keys that exist in English locale files.

Learnt from: userquin
Repo: npmx-dev/npmx.dev PR: 1096
File: i18n/locales/es-419.json:34-41
Timestamp: 2026-02-06T14:53:23.339Z
Learning: In the npmx.dev project, when using country locale variants (e.g., es-419, es-ES), place only translations that differ from the base language in variant JSON files (e.g., es-419.json). The base file (es.json) is loaded first, then the variant file overlays any keys it defines. This behavior is provided by vue-i18n's multiple-files feature. See CONTRIBUTING.md under 'Country variants (advanced)' for details.

"github": "View on GitHub",
"gitlab": "View on GitLab",
"bitbucket": "View on Bitbucket",
"codeberg": "View on Codeberg",
"git_repo": "View on Git repository",
"forgejo": "View on Forgejo",
"gitea": "View on Gitea",
"gitee": "View on Gitee",
"radicle": "View on Radicle",
"sourcehut": "View on SourceHut",
"tangled": "View on Tangled"
}
},
"profile": {
"display_name": "Display Name",
Expand Down Expand Up @@ -312,7 +325,6 @@
"readme": {
"title": "Readme",
"no_readme": "No README available.",
"view_on_github": "View on GitHub",
"toc_title": "Outline",
"callout": {
"note": "Note",
Expand Down
8 changes: 5 additions & 3 deletions i18n/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@
"skip_link": "Saltar al contenido principal",
"warnings": "Advertencias:",
"go_back_home": "Volver al inicio",
"view_on_npm": "ver en npm",
"per_week": "/ semana",
"vanity_downloads_hint": "Número de vanidad: no se muestran paquetes | Número de vanidad: para el paquete mostrado | Número de vanidad: Suma de {count} paquetes mostrados",
"sort": {
Expand All @@ -148,7 +147,11 @@
"cancel": "Cancelar",
"save": "Guardar",
"edit": "Editar",
"error": "Error"
"error": "Error",
"view_on": {
"npm": "ver en npm",
"github": "Ver en GitHub"
}
},
"profile": {
"display_name": "Nombre visible",
Expand Down Expand Up @@ -270,7 +273,6 @@
"readme": {
"title": "Léeme",
"no_readme": "No hay README disponible.",
"view_on_github": "Ver en GitHub",
"toc_title": "Índice",
"callout": {
"note": "Nota",
Expand Down
8 changes: 5 additions & 3 deletions i18n/locales/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@
"skip_link": "Passer au contenu principal",
"warnings": "Avertissements :",
"go_back_home": "Retour à l'accueil",
"view_on_npm": "voir sur npm",
"per_week": "/ semaine",
"vanity_downloads_hint": "Métrique de vanité : aucun paquet affiché | Métrique de vanité : pour le paquet affiché | Métrique de vanité : somme des {count} paquets affichés",
"sort": {
Expand All @@ -190,7 +189,11 @@
"cancel": "Annuler",
"save": "Enregistrer",
"edit": "Modifier",
"error": "Erreur"
"error": "Erreur",
"view_on": {
"npm": "voir sur npm",
"github": "Voir sur GitHub"
}
},
"profile": {
"display_name": "Nom d'affichage",
Expand Down Expand Up @@ -312,7 +315,6 @@
"readme": {
"title": "Readme",
"no_readme": "Aucun README disponible.",
"view_on_github": "Voir sur GitHub",
"toc_title": "Sommaire",
"callout": {
"note": "Note",
Expand Down
8 changes: 5 additions & 3 deletions i18n/locales/hi-IN.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,18 @@
"skip_link": "मुख्य सामग्री पर जाएं",
"warnings": "चेतावनियाँ:",
"go_back_home": "होम पर वापस जाएं",
"view_on_npm": "npm पर देखें",
"per_week": "/ सप्ताह",
"vanity_downloads_hint": "वैनिटी नंबर: कोई पैकेज प्रदर्शित नहीं | वैनिटी नंबर: प्रदर्शित पैकेज के लिए | वैनिटी नंबर: {count} प्रदर्शित पैकेज का योग",
"sort": {
"name": "नाम",
"role": "भूमिका",
"members": "सदस्य"
},
"scroll_to_top": "शीर्ष पर स्क्रॉल करें"
"scroll_to_top": "शीर्ष पर स्क्रॉल करें",
"view_on": {
"npm": "npm पर देखें",
"github": "GitHub पर देखें"
}
},
"package": {
"not_found": "पैकेज नहीं मिला",
Expand Down Expand Up @@ -195,7 +198,6 @@
"readme": {
"title": "रीडमी",
"no_readme": "कोई README उपलब्ध नहीं है।",
"view_on_github": "GitHub पर देखें",
"callout": {}
},
"provenance_section": {},
Expand Down
Loading
Loading