Added language support for year progress bar#52
Conversation
|
@dikshaaa316 is attempting to deploy a commit to the Dhanush Nehru's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Resolve merge conflict issues @dikshaaa316 |
There was a problem hiding this comment.
Pull Request Overview
Adds internationalization support to the year progress bar application, allowing users to select from multiple languages (English, Spanish, French, German, Hindi) with localized display text.
- Added language selection dropdown with 5 language options
- Implemented client-side language switching functionality
- Added server-side translation support for progress bar text
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| public/index.html | Added language selector UI and JavaScript function to handle language changes |
| api/app.js | Added translation dictionary and localization logic for progress bar text |
| package.json | Updated Express version from 4.21.0 to 4.21.2 |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| img.src = `http://localhost:3000/year-progress?${qs}&time=${Date.now()}`; | ||
| } | ||
| </script> | ||
|
|
||
|
|
||
| <img | ||
| id="progress-img" | ||
| src="https://year-in-progress.vercel.app/year-progress" | ||
| src="http://localhost:3000/year-progress" |
There was a problem hiding this comment.
Hardcoded localhost URL should be configurable or use relative URLs for production deployment. Consider using a relative path like /year-progress?${qs}&time=${Date.now()} instead.
| ).src = `http://localhost:3000/year-progress?${queryString}&time=${Date.now()}&theme=${theme}`; | ||
| } else { | ||
| document.getElementById( | ||
| "progress-img" | ||
| ).src = `https://year-in-progress.vercel.app/year-progress?time=${Date.now()}&theme=${theme}`; | ||
| ).src = `http://localhost:3000/year-progress?time=${Date.now()}&theme=${theme}`; |
There was a problem hiding this comment.
Hardcoded localhost URL should be configurable or use relative URLs for production deployment. Consider using a relative path like /year-progress?${queryString}&time=${Date.now()}&theme=${theme} instead.
| ).src = `http://localhost:3000/year-progress?${queryString}&time=${Date.now()}&theme=${theme}`; | ||
| } else { | ||
| document.getElementById( | ||
| "progress-img" | ||
| ).src = `https://year-in-progress.vercel.app/year-progress?time=${Date.now()}&theme=${theme}`; | ||
| ).src = `http://localhost:3000/year-progress?time=${Date.now()}&theme=${theme}`; |
There was a problem hiding this comment.
Hardcoded localhost URL should be configurable or use relative URLs for production deployment. Consider using a relative path like /year-progress?time=${Date.now()}&theme=${theme} instead.
| document.getElementById( | ||
| "progress-img" | ||
| ).src = `https://year-in-progress.vercel.app/year-progress?${queryString}`; | ||
| ).src = `http://localhost:3000/year-progress?${queryString}`; |
There was a problem hiding this comment.
Hardcoded localhost URL should be configurable or use relative URLs for production deployment. Consider using a relative path like /year-progress?${queryString} instead.
| en: `Completed`, | ||
| es: `Completado`, | ||
| fr: `Terminé`, | ||
| de: `Abgeschlossen`, | ||
| hi: `पूरा हुआ`, | ||
| }; | ||
|
|
||
| const localizedText = `${progressFormatted}% of ${currentYear} ${translations[lang] || translations["en"]}`; | ||
|
|
There was a problem hiding this comment.
The word order assumption may not work for all languages. Consider using a more flexible template system like ${progressFormatted}% ${translations[lang]?.template || translations.en.template} where each language can define its own sentence structure.
| en: `Completed`, | |
| es: `Completado`, | |
| fr: `Terminé`, | |
| de: `Abgeschlossen`, | |
| hi: `पूरा हुआ`, | |
| }; | |
| const localizedText = `${progressFormatted}% of ${currentYear} ${translations[lang] || translations["en"]}`; | |
| en: { | |
| template: "{progress}% of {year} Completed" | |
| }, | |
| es: { | |
| template: "{progress}% del {year} Completado" | |
| }, | |
| fr: { | |
| template: "{progress}% de {year} Terminé" | |
| }, | |
| de: { | |
| template: "{progress}% von {year} Abgeschlossen" | |
| }, | |
| hi: { | |
| template: "{year} का {progress}% पूरा हुआ" | |
| } | |
| }; | |
| function formatTemplate(template, values) { | |
| return template.replace(/{(\w+)}/g, (_, key) => values[key] ?? ""); | |
| } | |
| const template = (translations[lang]?.template) || translations["en"].template; | |
| const localizedText = formatTemplate(template, { | |
| progress: progressFormatted, | |
| year: currentYear | |
| }); |
|
@DhanushNehru, merge conflicts are resolved. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| img.src = `http://localhost:3000/year-progress?${qs}&time=${Date.now()}`; | ||
| } | ||
| </script> | ||
|
|
||
|
|
||
| <img | ||
| id="progress-img" | ||
| src="https://year-in-progress.vercel.app/year-progress" | ||
| src="http://localhost:3000/year-progress" |
There was a problem hiding this comment.
Hardcoded localhost URL will break in production. Consider using a relative URL or environment-based configuration.
| img.src = `http://localhost:3000/year-progress?${qs}&time=${Date.now()}`; | ||
| } | ||
| </script> | ||
|
|
||
|
|
||
| <img | ||
| id="progress-img" | ||
| src="https://year-in-progress.vercel.app/year-progress" | ||
| src="http://localhost:3000/year-progress" |
There was a problem hiding this comment.
Hardcoded localhost URL will break in production. Consider using a relative URL like '/year-progress'.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@dikshaaa316 do resolve the issues pointed by copilot |
No description provided.