-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
feat: Localize file-based dynamic routes #654
feat: Localize file-based dynamic routes #654
Conversation
This feature adds the ability to have localized routes under the _routes folder. This is done by creating all the possible slugs on the fly based on the site.config.available_locales. Every routes will have I18n.locale already configured and the locale passed also through r.params[:locale]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tommasongr Very nicely done. I had one little code nitpick, but otherwise LGTM. 👍
@tommasongr Looks like some Rubocop checks are failing. I'd be fine with adding some |
@jaredcwhite Thanks for reporting it. Yeah, I was aware of that. I fixed all the "real" offenses, but I wasn't sure how to treat the Metrics one. Anyway I'll comment/fix all the remaining offenses and push a final commit. Give me a sec. |
@jaredcwhite I resolved three offenses in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Summary
Adds localized routes under the
_routes
folder. This is done by creating all the possible slugs on the fly based onsite.config.available_locales
.Every route will set
I18n.locale
andr.params[:locale]
to the corresponding value extracted from the url slug.A possible missing piece might be a dedicated config for opting-in/out from the behavior. However, I think that forcing the locale on the file frontmatter could be a good enough alternative and possibly a more granular one.