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

Default Translations not added #97

Closed
thchia opened this issue Jun 23, 2018 · 1 comment
Closed

Default Translations not added #97

thchia opened this issue Jun 23, 2018 · 1 comment
Assignees
Labels

Comments

@thchia
Copy link
Collaborator

thchia commented Jun 23, 2018

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
Default translations are not added. Instead the "Missing translationId..." text is displayed.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:
https://codesandbox.io/s/v34q286o45

What is the expected behavior?
Default Translation is added.

Which versions of react and react-localize-redux are you using?
react v16.3.2
react-localize-redux v3.1.1

Solution

I believe this problem is caused because the default translations are added:

  1. on mount;
  2. on update if props.id has changed.

In both cases the default translation is added subject to certain conditions checked in addDefaultTranslation(), namely that there is a defaultLanguage.

On initial mount (1), the defaultLanguage is undefined, which means the default translations are not added. When the defaultLanguage comes through on a subsequent rerender (2), addDefaultTranslation() is not called because props.id has not changed.

@ryandrewjohnson
Copy link
Owner

Fixed in #99. Thanks @thchia.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants