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

Use Current API #14

Open
virolea opened this issue Sep 29, 2024 · 0 comments
Open

Use Current API #14

virolea opened this issue Sep 29, 2024 · 0 comments
Assignees

Comments

@virolea
Copy link
Owner

virolea commented Sep 29, 2024

The initial implementation of the locale per thread was done manually by setting Thread.current[:rosetta_locale_session] to an instance of Rosetta::LocaleSession.

This model encapsulates the logic of finding the correct locale based on the supplied input and fallback to the default locale if not found. This works well but I wondered if we'd be better off simply using the Rails CurrentAtributes API.

  • It's reset after each request, removing the need for Rosetta#with_locale to ensure the locale is set back to whatever it was before
  • It's built-in rails
  • One less thread-related consideration in the code, this simplifies things.

Warning

CurrentAttributes being a thread level singleton instance, one needs to be careful not to override any potential user-defined attribute.

@virolea virolea self-assigned this Sep 29, 2024
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

No branches or pull requests

1 participant