Skip to content

feat: added translation feature#15

Merged
abielzulio merged 7 commits intocomuline:mainfrom
rioarray:feature/translation
Apr 3, 2025
Merged

feat: added translation feature#15
abielzulio merged 7 commits intocomuline:mainfrom
rioarray:feature/translation

Conversation

@rioarray
Copy link
Contributor

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.

@abielzulio
Copy link
Collaborator

Hi, @rioarray!

Thank you for your PR. This is my first time using the react-i18next package. I noticed that the initial language for the time is set to en-US, while the others remain in Bahasa Indonesia. Is that the intended default behavior? Can we set all the text to Bahasa Indonesia by default?

CleanShot.2025-03-30.at.22.00.26.mp4

@abielzulio abielzulio changed the title added translation feature feat: added translation feature Mar 30, 2025
@rioarray
Copy link
Contributor Author

rioarray commented Apr 2, 2025

Hi, @rioarray!

Thank you for your PR. This is my first time using the react-i18next package. I noticed that the initial language for the time is set to en-US, while the others remain in Bahasa Indonesia. Is that the intended default behavior? Can we set all the text to Bahasa Indonesia by default?

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.

@abielzulio
Copy link
Collaborator

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

@rioarray
Copy link
Contributor Author

rioarray commented Apr 2, 2025

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

@abielzulio abielzulio requested a review from Copilot April 3, 2025 02:55
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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")} +
Copy link

Copilot AI Apr 3, 2025

Choose a reason for hiding this comment

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

[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.

Suggested change
{t("Tambahkan stasiun dengan menekan tombol")} +
{t("Tambahkan stasiun dengan menekan tombol +")}

Copilot uses AI. Check for mistakes.
@abielzulio abielzulio merged commit 0afbb7c into comuline:main Apr 3, 2025
1 check passed
@abielzulio
Copy link
Collaborator

Merged. Thank you for your contributions! @rioarray

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.

2 participants