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

Users have no way to permanently change their locale #2175

Open
toolness opened this issue Aug 12, 2021 · 0 comments
Open

Users have no way to permanently change their locale #2175

toolness opened this issue Aug 12, 2021 · 0 comments

Comments

@toolness
Copy link
Collaborator

toolness commented Aug 12, 2021

We have a locale property in the JustfixUser model that is set when the user first creates their account; it's based on the language the user is using at the time. It's used in a number of places, particularly in situations where we don't have access to a Django HTTP request object to get information about what language the user is currently using (such as scheduled and asynchronous tasks, e.g. the NoRent SMS reminder we send monthly).

However, what we don't currently offer is a way for users to change that locale. If a user decides to use the language selection widget at the top-right of the site to change their language, that's just site navigation--we don't currently use that action to change the locale property in the user model. Actually potentially changing the user's locale on every page view and/or used the language dropdown might not scale very well, though. It might also result in unintentional changes to the user's locale, e.g. if the user followed a hard-coded link to app.justfix.nyc/en/ from another site, even though they preferred Spanish.

One alternative is that we could add middleware to our GraphQL pipeline that looks at the current locale used by the user whenever they make a mutation (i.e., whenever they submit a form); if they're logged-in and their current locale is different from whatever their user model thinks it is, we modify their user model to be in-sync. This way, whatever language the user most recently submitted a form with is the language that the whole Tenant Platform thinks the user is using. I feel like this is probably the most in-line with user expectations, and also wouldn't be hard to implement.

(As an alternative to GraphQL middleware, which I've never actually written before and may end up being more complex than I assume, we could simply modify our DjangoFormMutation class in project/util/django_graphql_forms.py to do this logic for us, since almost all our mutations subclass from it.)

Another possibility, which isn't necessarily mutually exclusive with the aforementioned solution, is to add a "language" setting to the account settings page, which directly controls the user's locale property. It might seem confusing to users, though, to have both a dropdown at the top-right of the page and an account setting for the same thing.

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