Skip to content

Use Current API #14

@virolea

Description

@virolea

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions