Skip to content

fix: localize warning messages#2133

Draft
maxchang3 wants to merge 1 commit intonpmx-dev:mainfrom
mcontrib:fix/2049-warning-i18n
Draft

fix: localize warning messages#2133
maxchang3 wants to merge 1 commit intonpmx-dev:mainfrom
mcontrib:fix/2049-warning-i18n

Conversation

@maxchang3
Copy link
Contributor

@maxchang3 maxchang3 commented Mar 18, 2026

🔗 Linked issue

resolves #2049

🧭 Context

Some warnings shown in the skills modal and diff sidebar were previously hardcoded English strings produced on the server.

This change localizes those warnings by returning structured warning messages with translation keys, then translating them in the UI through a shared composable.

📚 Description

Changes:

  • introduce a shared WarningMessage type for structured warnings
  • Update server-side warning generation to return translation keys instead of raw strings
  • add corresponding i18n entries and schema updates
  • translate warnings in the UI via useI18nWarning()
  • update related tests

I went back and forth a bit on whether these warnings should remain entirely client-derived, since there are already places in the project where warning-like UI text is built on the frontend.

Following the discussion in #2049 with @ShroXd, it felt worthwhile to establish this pattern here: it not only improves i18n handling, but also gives us a clearer structure for information flow, while translation keys remain semantic and readable.

So this PR also serves as an experiment to explore what this direction would look like in practice.


One thing to note is that this also introduces a dynamic key mechanism that isn't currently accepted by the existing i18n validation.

❌ Unused keys: 3
  ./i18n/locales/en.json
    package.skills.warnings.no_license
    package.skills.warnings.no_compatibility
    compare.warnings.files_truncated

❌ Build failed: missing, unused or dynamic keys detected

@vercel
Copy link

vercel bot commented Mar 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Mar 18, 2026 5:04pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Mar 18, 2026 5:04pm
npmx-lunaria Ignored Ignored Mar 18, 2026 5:04pm

Request Review

@github-actions
Copy link

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

File Note
i18n/locales/en.json Source changed, localizations will be marked as outdated.
i18n/locales/zh-CN.json Localization changed, will be marked as complete.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

@codecov
Copy link

codecov bot commented Mar 18, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
app/components/Package/SkillsModal.vue 0.00% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Some server-side generated warnings are hardcoded

1 participant