-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add some support for internationalization to the route system #502
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds some support for internationalization, using Django's built-in support for it, along with some bespoke code for managing locale-prefixed routes in our front-end JS.
A new
ENABLE_I18N
environment variable, which defaults to false, now controls whether internationalization is enabled.If enabled, non-localized paths will automatically be localized, e.g.
/
will redirect to/en/
(since that's the only language we support right now). This is done via Django'si18n_patterns()
.This PR does not add support for actually localizing content on the JS side. We're still exploring various solutions for that--see #12 for more details.
That said, this PR does add some minor localization: since the GraphQL endpoint is now internationalized, generic form validation errors that are coming from core Django, like "This field is required", will be translated to the current locale, which is nice.
To do
ENABLE_I18N
setting to enable internationalization.At present, definitive django-handled 404s in our letter and hp action routes get redirected to locale-prefixed routes, which is rather annoying. It might just be easier to have those be locale-prefixed to begin with, so that this doesn't happen, and so we can eventually localize those routes if it's beneficial to do so.We're just prefixing all our hp and loc routes with the locale, so 404s will 404.i18n_patterns()
does this automatically for us.