feat(i18n): add ?lang= support to /api/wrapped (Year in Review) badge#5803
feat(i18n): add ?lang= support to /api/wrapped (Year in Review) badge#5803vanshikaMaheshwari wants to merge 2 commits into
Conversation
|
@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. |
Aamod-Dev
left a comment
There was a problem hiding this comment.
Difficulty: intermediate – Adds ?lang= i18n support to /api/wrapped Year in Review badge.
Quality: clean – Internationalization.
Type: feature – Localization support.
Great i18n feature!
Aamod-Dev
left a comment
There was a problem hiding this comment.
Review
Already labeled. Adds lang parameter to wrappedParamsSchema and passes it to wrapped SVG generation. Includes i18n test coverage.
Approved! 🚀
Aamod-Dev
left a comment
There was a problem hiding this comment.
Adding i18n support for the /api/wrapped\ badge is a fantastic improvement for global accessibility! Passing the \lang\ parameter and wiring it into \lib/i18n/badgeLabels.ts\ brings this badge up to parity with the rest of the application. The comprehensive test suite in \�pp/api/wrapped/tests/i18n.test.ts\ is also very much appreciated. Approved!
Description
Fixes #5787
What does this PR do?
Adds
langquery 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/wrappedbadge 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— extendedBadgeLabelsinterface 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— addedlang: z.enum(supportedLanguages).catch('en').default('en')towrappedParamsSchemaapp/api/wrapped/route.ts— destructuredlangfrom parsed params and passed it intoBadgeParamslib/svg/generator.ts— calledgetLabels(params.lang)ingenerateWrappedSVGand replaced all 5 hardcoded English strings with label lookupslib/i18n/badgeLabels.test.ts— addedwrapped / year-in-review keysdescribe blockapp/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 FrenchPillar
Visual Preview
Before (
?lang=hi): labels render in EnglishAfter (
?lang=hi): labels render in HindiChecklist before requesting a review:
CONTRIBUTING.mdfile.localhost:3000/api/streak?user=YOUR_USERNAME).npm run formatandnpm run lintlocally and resolved all errors (CI will fail otherwise).feat(themes): ...,fix(calculate): ...).README.mdif I added a new theme or URL parameter.