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

Support per-document locale permalinks and config #162

Merged
merged 3 commits into from
Oct 29, 2020

Conversation

jaredcwhite
Copy link
Member

Partially addresses #49

This PR does four important things:

  1. It sets the locale front matter of a document (if it's not set explicitly) by looking for language or lang front matter or finally the filename pattern slug.locale.ext (which might be the preferable way to do things).
  2. It strips out the last locale slug segment (if present) when generating the destination URL/path.
  3. You can configure posts or other collection permalinks to output to a dedicated top-level folder when a document locale is set…e.g., _collection/my-cool-doc.es.md would become /es/collection/my-cool-doc, whereas _collection/my-cool-doc.md would remain /collection/my-cool-doc
  4. When a document locale is set, site.locale is set to the document locale when that document is being rendered, so you can take advantage of the site.locale value in layout templates, components, partials, using the t translation helper, etc.

Note: none of this applies to pages at present, only documents (essentially any content type not a page).

There's more work to do to investigate patterns and potential fixes needed across the whole codebase to handle multilingual content (for example, if you want to loop through blog posts on language-specific index pages using pagination…how do you do that?), but this is a good step in the right direction.

@jaredcwhite jaredcwhite added this to the 0.18.0 "Taylor Street" milestone Oct 19, 2020
@jaredcwhite jaredcwhite added the enhancement New feature or request label Oct 19, 2020
@jaredcwhite jaredcwhite merged commit a2c15c1 into main Oct 29, 2020
@jaredcwhite jaredcwhite deleted the multiple-language-paths branch October 29, 2020 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant