carlossalasamper / react-clean-architecture

🧅 A clean architecture scaffold in React that is easy to understand.
MIT License
4 stars 2 forks source link

Issue with i18n - Error when modifying translation files #1

Closed olarra closed 3 months ago

olarra commented 3 months ago

Hello,

There is an issue related to i18n in the project. Initially, it works fine, but when making modifications to the translation files en.ts or es.ts, an error appears in the console:


Error: No matching bindings found for serviceIdentifier: Symbol(I18nClass)
Symbol(I18nClass) - tagged: { key:provided, value: true }

If the Expo application is restarted, everything works fine again, but modifications to the text cannot be made without refreshing the application.

The issue seems to be in the service /core/presentation/i18n on the line:

this.i18nJs = new I18nJs(locales);

Even when doing it inline like this:

const i18n = new I18n({
  en: {
    hello: "Hi!",
  },
  es: {
    hello: "Olá!",
  },
});

and modifying the translations, the error still occurs.

I tried making some modifications and defining the service like the rest of the global services, but without success:

{
  isGlobal: true,
  provide: I18nToken,
  useClass: I18nClass,
}

I have tried to investigate the source of the problem but have not found a solution yet.

Steps to Reproduce:

Start the application.

Modify the en.ts or es.ts translation files.

Observe the error in the console.

Expected Behavior: Modifications to the translation files should not cause the application to error out and should reflect the changes dynamically.

Additional Context: Any help or guidance on resolving this issue would be greatly appreciated.

olarra commented 3 months ago

The answer was to use Symbol.for https://stackoverflow.com/questions/60324374/inversifyjs-passing-container-to-another-object-causes-binding-resolution-to-fa

olarra commented 3 months ago

The answer was to use Symbol.for https://stackoverflow.com/questions/60324374/inversifyjs-passing-container-to-another-object-causes-binding-resolution-to-fa