Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve i18n support as a whole #1526

Merged
merged 6 commits into from
Apr 15, 2023

Conversation

lincolnthalles
Copy link
Contributor

  • Remove dayjs in favor of /helpers/datetime.ts, which uses Intl.DateTimeFormat and Date. Dayjs is not exactly i18n friendly and has several locale related opened issues.

  • Move/refactor date/time code from /helpers/utils.ts to /helpers/datetime.ts.

  • Fix Daily Review weekday not changing according to selected date.

  • Localize Daily review weekday and month.

  • Load i18n listed strings from /locales/{locale}.json in a dynamic way. This makes much easier to add new locales, by just adding a properly named json file and listing it only in /web/src/i18n.ts and /api/user_setting.go.

  • Fallback languages are now set in /web/src/i18n.ts.

  • Full language codes are now preffered, but they fallback to 2-letter codes when not available.

  • The locale dropdown is now populated dynamically from the available locales. Locale names are populated by the browser via Intl.DisplayNames(locale).

  • /web/src/i18n.ts now exports a type TLocale from availableLocales array. This is used only by findNearestLanguageMatch(). As I was unable to use this type in ".d.ts" files, I switched the Locale type from /web/src/types/i18n.d.ts to string.

  • Move pretty much all hardcoded text strings to i18n strings.

  • Add pt-BR translation.

  • Remove site.ts and move its content to a i18n string.

  • Rename zh.json to zh-Hans.json to get the correct language name on selector dropdown.

  • Remove pt_BR.json and replace with pt-BR.json.

  • Some minor layout spacing fixes to accommodate larger texts.

  • Improve some error messages.

There are lots of small changes, but I also took some time testing and it should work fine.

- Remove dayjs in favor of /helpers/datetime.ts, which uses
Intl.DateTimeFormat and Date. Dayjs is not exactly i18n friendly
and has several locale related opened issues.

- Move/refactor date/time code from /helpers/utils.ts to
/helpers/datetime.ts.

- Fix Daily Review weekday not changing according to selected date.

- Localize Daily review weekday and month.

- Load i18n listed strings from /locales/{locale}.json in a dynamic way.
This makes much easier to add new locales, by just adding a properly
named json file and listing it only in /web/src/i18n.ts and
/api/user_setting.go.

- Fallback languages are now set in /web/src/i18n.ts.

- Full language codes are now preffered, but they fallback to 2-letter
codes when not available.

- The locale dropdown is now populated dynamically from the available
locales. Locale names are populated by the browser via
Intl.DisplayNames(locale).

- /web/src/i18n.ts now exports a type TLocale from availableLocales
array. This is used only by findNearestLanguageMatch(). As I was unable
to use this type in ".d.ts" files, I switched the Locale type from
/web/src/types/i18n.d.ts to string.

- Move pretty much all hardcoded text strings to i18n strings.

- Add pt-BR translation.

- Remove site.ts and move its content to a i18n string.

- Rename zh.json to zh-Hans.json to get the correct language name on
selector dropdown.

- Remove pt_BR.json and replace with pt-BR.json.

- Some minor layout spacing fixes to accommodate larger texts.

- Improve some error messages.
@lincolnthalles lincolnthalles requested a review from boojack as a code owner April 13, 2023 20:57
@github-actions
Copy link

github-actions bot commented Apr 13, 2023

Uffizzi Preview deployment-22193 was deleted.

@boojack boojack requested a review from CorrectRoadH April 13, 2023 22:51
Copy link
Contributor

@CorrectRoadH CorrectRoadH left a comment

Choose a reason for hiding this comment

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

LGTM

web/package-lock.json Outdated Show resolved Hide resolved
Copy link
Collaborator

@boojack boojack left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for your contribution!

web/yarn.lock Show resolved Hide resolved
@boojack boojack merged commit 557278f into usememos:main Apr 15, 2023
@boojack
Copy link
Collaborator

boojack commented Apr 15, 2023

BTW, what's your yarn version?

yarn -v

@lincolnthalles
Copy link
Contributor Author

BTW, what's your yarn version?

yarn -v

It's the latest, 3.5.0, and node = 18.15.0

@lincolnthalles lincolnthalles deleted the improve-i18n-support branch May 13, 2023 15:24
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.

3 participants