aws-amplify / aws-amplify/amplify-ui
FR (Authenticator): Support dynamic text update when changing languages
- Dominant language
- TypeScript
- Stars
- 1.1k
- Forks
- 347
- Avg merge
- 18h 29m
- Merged PRs (30d)
- 9
Description
**Is your feature request related to a problem? Please describe.**
Components are not re-rendering on `I18n.setLanguage`. Components are rendering initial language strings correctly but they do not re-render on language change.
_Relates to aws-amplify/amplify-js#6346 aws-amplify/amplify-js#6115 #6962_
**Describe the solution you'd like**
Components should re-render on `I18n.setLanguage`
_Suggestion from @ericclemmons https://github.com/aws-amplify/amplify-js/pull/6346#issuecomment-710227501 :_
> If I18n.setLanguage fired a Hub event, we _could_ re-render the component 🤔
> https://github.com/aws-amplify/amplify-js/blob/377acd0507e6d4be34bf36ea9c0694fa98ac04b1/packages/core/src/I18n/I18n.ts#L64-L66
**Describe alternatives you've considered**
1. Force re-render using `key` attribute
```jsx
```
Force re-creating the components will result in a screen flicker and loss of component state
2. Specifying all texts in props
```jsx
```
Doable but a big hassle : D
**Additional context**
This is happening in `@aws-amplify/ui-react`.
Need to check if other ui-components e.g. angular, vue, etc exhibit the same behavior.
Contributor guide
Research direction
Start with packages/core/src/I18n/I18n.ts, especially the setLanguage path referenced in the issue, and inspect how @aws-amplify/ui-react components obtain translated text. Check whether other UI components such as Angular or Vue have the same behavior. Done means components re-render after I18n.setLanguage without a key workaround, screen flicker, or loss of component state.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend, internationalization
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100