geostyler / geostyler-sld-parser

GeoStyler-Style-Parser implementation for SLD
BSD 2-Clause "Simplified" License
51 stars 30 forks source link

SLD parser causes i18next issue in projects that use i18next #944

Open hwbllmnn opened 3 months ago

hwbllmnn commented 3 months ago

Bug

Describe the bug

The initialization of i18next in the parser causes the initialization in downstream projects to fail. If using e.g. the fetch backend will not run (will not fetch the i18n files) in case the initialization in the SLD parser runs first.

To Reproduce Steps to reproduce the behavior:

Embed the SLD parser in a project that also uses i18next (or react-i18next).

Expected behavior

I'd expect the i18next usage in the SLD parser not to influence the usage in downstream projects.

Desktop (please complete the following information):

Happens in all browsers.

Additional context

The initialization of i18next should probably be managed by configuration or by construction option. Perhaps a i18next configuration module could be created that can be used by downstream projects.

marcjansen commented 3 months ago

I am a bit surprised. Why does a parser need i18next at all?

hwbllmnn commented 3 months ago

This was added during the codesprint in Paris to enable localized error messages, which in principle I like. I was also surprised that i18next seems so inflexible regarding initialization (especially since in react it uses a proper context which obviously still doesn't prevent polluting the globals).

KaiVolland commented 3 months ago

I suggested @ocruze to use i18next. He started with a different library but i told him that we use i18next elsewhere and it works well... :man_facepalming:

ocruze commented 3 months ago

Actually initially I didn't use any library at all, it was pure ts types. Maybe I can make another proposal with ts types and you can revert my PR?

KaiVolland commented 3 months ago

Yeah this would be great. I'm afraid that this is kind of blocking the release of geostyler / geostyler-demo.