feat: added translation feature#15
Conversation
|
Hi, @rioarray! Thank you for your PR. This is my first time using the CleanShot.2025-03-30.at.22.00.26.mp4 |
Hi @abielzulio, thanks for reviewed. I was fix that in the latest commit. So the default languange (include time) will be indonesian format. |
…le with new Indonesian text
|
Nice. Thank you! One thing I'd like to do is how we visualize the language control. How would you feel about moving it to the footer to make the top bar look simpler and cleaner? @rioarray CleanShot.2025-04-02.at.21.53.12.mp4 |
Moving the translation switcher into footer LGTM too @abielzulio. Cool +1 |
There was a problem hiding this comment.
Pull Request Overview
This PR implements a new translation feature and adds support for a 12-hour time format for the English language throughout the application.
- Updates time formatting functions to conditionally format times based on language.
- Introduces i18n configuration, Language types, and a language-switching hook.
- Applies translation functions in UI components and integrates language-based placeholders.
Reviewed Changes
Copilot reviewed 8 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/utils/time.ts | Updates functions for relative time and date formatting with language-dependent patterns. |
| src/libs/i18n/types.ts | Adds a Language type to support i18n. |
| src/libs/i18n/config.ts | Sets up i18n configuration for initializing translation resources. |
| src/hooks/use-language.ts | Implements a language switching hook that syncs date-fns locales with chosen language. |
| src/components/station-item.tsx | Integrates translation calls and adapts time formatting based on selected language. |
| src/components/footer.tsx | Introduces language toggle buttons and translated footer text. |
| src/app.tsx | Integrates language-based placeholders and translated messages in the main application. |
Files not reviewed (2)
- package.json: Language not supported
- src/libs/i18n/en/translation.json: Language not supported
Comments suppressed due to low confidence (1)
src/utils/time.ts:12
- The removal of the 'locale' parameter from 'formatDistanceToNow' may result in non-localized relative time outputs for languages other than 'id'. Consider passing the proper locale based on the current language or document this change if intentional.
return formatDistanceToNow(todayDate);
| </h1> | ||
| <span className="text-sm opacity-50"> | ||
| Tambahkan stasiun dengan menekan tombol + | ||
| {t("Tambahkan stasiun dengan menekan tombol")} + |
There was a problem hiding this comment.
[nitpick] Concatenating a plus sign outside the translation call may lead to formatting issues in different languages. Consider including the '+' within the translation string to ensure consistent localization.
| {t("Tambahkan stasiun dengan menekan tombol")} + | |
| {t("Tambahkan stasiun dengan menekan tombol +")} |
|
Merged. Thank you for your contributions! @rioarray |
Hi, I added translation feature for this app with 12h time format for english language. This is the preview. If any feedback, don't hesitate to mention me. Thank you.