Skip to content

feat(i18n): add ?lang= support to /api/wrapped (Year in Review) badge#5803

Open
vanshikaMaheshwari wants to merge 2 commits into
JhaSourav07:mainfrom
vanshikaMaheshwari:main
Open

feat(i18n): add ?lang= support to /api/wrapped (Year in Review) badge#5803
vanshikaMaheshwari wants to merge 2 commits into
JhaSourav07:mainfrom
vanshikaMaheshwari:main

Conversation

@vanshikaMaheshwari

Copy link
Copy Markdown

Description

Fixes #5787

What does this PR do?

Adds lang query parameter support to the /api/wrapped ("Year in Review") badge, bringing it in line with every other badge in the CommitPulse family (/api/streak, monthly stats, heatmap, versus, languages, etc.).

Problem

The /api/wrapped badge had all 5 label strings (TOTAL CONTRIBUTIONS, TOP LANGUAGE, WEEKEND GRIND, PEAK DAY, BUSIEST MONTH) hardcoded in English inside the SVG template. Passing ?lang=hi (or any other supported language) had no effect, breaking the localization promise advertised for the rest of the badge family.

Changes

  • lib/i18n/badgeLabels.ts — extended BadgeLabels interface with 5 new wrapped-specific keys and added translations for all 10 existing locales (en, zh, es, hi, pt, ko, ja, fr, ta, de)
  • lib/validations.ts — added lang: z.enum(supportedLanguages).catch('en').default('en') to wrappedParamsSchema
  • app/api/wrapped/route.ts — destructured lang from parsed params and passed it into BadgeParams
  • lib/svg/generator.ts — called getLabels(params.lang) in generateWrappedSVG and replaced all 5 hardcoded English strings with label lookups
  • lib/i18n/badgeLabels.test.ts — added wrapped / year-in-review keys describe block
  • app/api/wrapped/tests/i18n.test.ts — new test file covering schema defaulting, all locales accepted, unsupported locale coercion, and translation spot-checks for Hindi, Japanese, and French

Pillar

  • 🎨 Pillar 1 — New Theme Design
  • 📐 Pillar 2 — Geometric SVG Improvement
  • 🕐 Pillar 3 — Timezone Logic Optimization
  • 🛠️ Other (Bug fix, refactoring, docs)

Visual Preview

Before (?lang=hi): labels render in English
After (?lang=hi): labels render in Hindi

Checklist before requesting a review:

  • I have read the CONTRIBUTING.md file.
  • I have tested these changes locally (localhost:3000/api/streak?user=YOUR_USERNAME).
  • I have run npm run format and npm run lint locally and resolved all errors (CI will fail otherwise).
  • My commits follow the Conventional Commits format (e.g., feat(themes): ..., fix(calculate): ...).
  • I have updated README.md if I added a new theme or URL parameter.
  • I have started the repo.
  • I have made sure that i have only one commit to merge in this PR.
  • The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts).
  • (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.

@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

@vanshikaMaheshwari is attempting to deploy a commit to the jhasourav07's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added status:blocked This PR is blocked due to a failing CI check. and removed status:blocked This PR is blocked due to a failing CI check. labels Jun 16, 2026

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Great i18n feature

@github-actions github-actions Bot added status:blocked This PR is blocked due to a failing CI check. and removed status:blocked This PR is blocked due to a failing CI check. labels Jun 17, 2026
@Aamod-Dev Aamod-Dev added level:intermediate Moderate complexity tasks quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. type:feature New features, additions, or enhancements mentor:Aamod007 labels Jun 18, 2026

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Difficulty: intermediate – Adds ?lang= i18n support to /api/wrapped Year in Review badge.

Quality: clean – Internationalization.

Type: feature – Localization support.

Great i18n feature!

@github-actions github-actions Bot added status:blocked This PR is blocked due to a failing CI check. and removed status:blocked This PR is blocked due to a failing CI check. labels Jun 18, 2026

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review

Already labeled. Adds lang parameter to wrappedParamsSchema and passes it to wrapped SVG generation. Includes i18n test coverage.

Approved! 🚀

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

Labels

level:intermediate Moderate complexity tasks mentor:Aamod007 quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. type:feature New features, additions, or enhancements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add lang/i18n support to /api/wrapped (Year in Review badge)

3 participants