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

i18n support #482

Merged
merged 3 commits into from
Oct 13, 2021
Merged

i18n support #482

merged 3 commits into from
Oct 13, 2021

Conversation

saulipurhonen
Copy link
Contributor

@saulipurhonen saulipurhonen commented Oct 7, 2021

Description

Introduced i18n support with react-i18next library.
Selection is stored in local storage. This helps to render correct translation when user chooses locale on login page.

Related issues

Closes #21

Type of change

  • New feature (non-breaking change which adds functionality)

Changes Made

  • Added i18n configuration file to src path
  • Language selector on top navigation with MUI Menu component
  • Store locale selection to browsers local storage and redux state
  • Utility function for navigating with selected locale
  • Changed navigation items to navigate with locale
  • Added translation files to src/translations
  • Translated "Logged in as" string on /home route.
  • Added fallback for user templates in UserDraftTemplates. This caused some issues if templates resulted as undefined

Testing

  • E2E

@saulipurhonen saulipurhonen added the enhancement New feature or request label Oct 7, 2021
@saulipurhonen saulipurhonen added this to the Open Beta milestone Oct 7, 2021
@saulipurhonen saulipurhonen self-assigned this Oct 7, 2021
@saulipurhonen
Copy link
Contributor Author

Initial approach was to use React Routers basename as dynamic base URL and this way to reduce the need to insert locale on link paths. However dynamic basename isn't supported and only way I got it working was to restart the whole app. This would stray away from seamless design and would reset the redux state.

Therefore I decided to go with local storage / locale in redux state combination.

@saulipurhonen saulipurhonen marked this pull request as ready for review October 7, 2021 16:06
@saulipurhonen saulipurhonen linked an issue Oct 7, 2021 that may be closed by this pull request
@saulipurhonen
Copy link
Contributor Author

Issue #21 includes feature requests for both JSON schema based forms and AJV validation.
To reduce weight on this PR I think we should do these two on separate PR's.

Copy link
Contributor

@hannyle hannyle left a comment

Choose a reason for hiding this comment

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

For me the components inside <NewDraftWizard/> seem not completely worked with translation. For example, WizardCreateFolderStep is missing the query params when changing language.

@saulipurhonen
Copy link
Contributor Author

For me the components inside <NewDraftWizard/> seem not completely worked with translation. For example, WizardCreateFolderStep is missing the query params when changing language.

Query parameters are now included in language change method.

Copy link
Contributor

@lilachic lilachic left a comment

Choose a reason for hiding this comment

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

LGTM. This contains a lot just to introduce locale for a another language. I'm not sure if its relevant but clicking En/Fi button in listing of folder content and details visible with "Show details" make the details hidden. For example http://localhost:3000/fi/home/published/{some id here}

@saulipurhonen
Copy link
Contributor Author

I'm not sure if its relevant but clicking En/Fi button in listing of folder content and details visible with "Show details" make the details hidden. For example http://localhost:3000/fi/home/published/{some id here}

Good call. This happens because language change updates locale in redux state and therefore the app re-renders components in navigation tree. Re-rendering is needed to get translations but I think that the opened details should be visible after language change. I'll look into it.

@saulipurhonen
Copy link
Contributor Author

I'm not sure if its relevant but clicking En/Fi button in listing of folder content and details visible with "Show details" make the details hidden. For example http://localhost:3000/fi/home/published/{some id here}

Good call. This happens because language change updates locale in redux state and therefore the app re-renders components in navigation tree. Re-rendering is needed to get translations but I think that the opened details should be visible after language change. I'll look into it.

This should be fixed now.

@saulipurhonen saulipurhonen merged commit 92bd679 into develop Oct 13, 2021
@saulipurhonen saulipurhonen deleted the feature/i18n-support branch October 13, 2021 10:12
@blankdots blankdots mentioned this pull request Apr 7, 2022
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add i18n internationalization support
4 participants