lingo.dev icon indicating copy to clipboard operation
lingo.dev copied to clipboard

lingo.dev/react/client should provides helper functions for custom LocaleSwitcher

Open galkin opened this issue 1 year ago • 5 comments

Today i updated my codebase from 0.109 to 0.110 and it breaks because of https://github.com/lingodotdev/lingo.dev/commit/e898c1eeb34e4dd3e74df26465802b520018acf9

For avoid such situation, could we export them from the lingo.dev/react/client as it described here https://github.com/lingodotdev/lingo.dev/blob/main/packages/react/src/client/utils.ts#L18 ?

Without that a developer must re-implement setLocaleInCookies and getLocaleFromCookies functions for custom LocaleSwitcher implemention and it creates risks for breaking changes.

galkin avatar Aug 06 '25 16:08 galkin

Yes, the helper function get/set locale in cookies is not intended to be consumed externally at the moment.

We are currently discussing this here on Discord. I think we will go forward and export the helper method under a proper name for custom locale switcher implementations.

mathio avatar Aug 06 '25 16:08 mathio

Hi, could you please assign this issue to me? I’ve reviewed the project’s Code of Conduct and Contribution Guidelines, and I have the required skills and understanding of the tech stack to work on this effectively. I’ve already started analyzing the codebase and begun initial work toward resolving the issue. I’m confident I can implement a clean, optimized, and maintainable solution that aligns with the project’s standards. Looking forward to contributing!

shbhmexe avatar Oct 29 '25 15:10 shbhmexe

@shbhmexe how would you approach this?

maxprilutskiy avatar Nov 11 '25 06:11 maxprilutskiy

Hi @maxprilutskiy, happy to take this on.

My proposed approach:

Export Helpers: Explicitly export getLocaleFromCookies and setLocaleInCookies from the lingo.dev/react/client entry point.

Consistency: Keep the internal logic identical to ensure backward compatibility and a seamless transition for users like @galkin who were previously relying on internal paths.

DX: Add basic TSDoc comments to these helpers since they will now be part of the public API.

Does that alignment work for you? If so, I’ll get a PR opened shortly.

Hellnight2005 avatar Feb 05 '26 09:02 Hellnight2005

@maxprilutskiy Can someone from the lingo.dev team take a look aswell?

Hellnight2005 avatar Feb 06 '26 14:02 Hellnight2005