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

[Experiment] feat: add translation-v2 & TranslationProvider-v2 #629

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nicoecheza
Copy link

@nicoecheza nicoecheza commented Jun 24, 2024

Update translation module & provider to stop depending on sagas and start using redux-toolkit instead. I'm not an expert on react but this seems to be working + has feature parity with the sagas version (tell me if I missed something).

Why?

Because I'm working on the editor standalone app and since the ui is based on the actual builder, I'm importing components from there, which depends on decentraland-dapps. And since a vast number of the components on builder use the translation module (and it's something we also want to have on the editor), I ported the module to "react 2024".

Extra info (just to leave this note somewhere)

Installing decentraland-dapps/@dcl/ui in a project with newer versions of react, webpack, etc has some compatibility problems that need to be addressed. We might need to check that out if we plan to eventually update everything to "state of the art" status.

Minimal API changes

Since there are no sagas, we lost the "observable" thing that it provides, and that we were using for auto-providing the fetchTranslation method for the TranslationProvider.
So now we have a thunk creator method called createTranslationFetcher which receives the translations and returns a thunk. That thunk is then used on the reducer to provide state updates based on the promise resolution and also in the TranslationProvider to fetch translations whenever the locale changes (same behaviour as before)

Create translation reducer:
Screenshot 2024-06-24 at 3 10 56 PM

fetchTranslation as prop for TranslationProvider:
Screenshot 2024-06-24 at 3 11 35 PM

This results in smaller code/less files, since there is not need to manually create some of the actions + we don't need a TranslationProvider.container.ts file anymore, and I'm probably missing something else.

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.

1 participant