Use i18n translated fields in slug template tags
See original GitHub issueContext
- i18n support:
- Slug template tags
Is your feature request related to a problem? Please describe. I’m not able to define a translated slug for each language using the i18n beta feature, the template tag uses the default language for all of them.
Describe the solution you’d like
Template tags should take the value from the field in its respective language ( {{slug}}
or {{title}}
are the ones I’m looking for)
Additional context This is my config file:
backend:
name: git-gateway
branch: master # Branch to update (optional; defaults to master)
local_backend: true
media_folder: static/img
public_folder: /img
i18n:
structure: multiple_folders
locales: [es, en]
default_locale: es
collections:
- name: "items"
label: "Items"
folder: "content/items"
create: true
slug: "{{title}}"
# slug: "{{slug}}"
media_folder: ""
public_folder: ""
i18n: true
editor:
preview: false
fields:
- { label: "Title", name: "title", widget: "string", i18n: true }
Then I publish a new “Item” with the following titles:
- Mi artículo
- My item
And it generates the following files:
.
├── en
│ └── mi-artículo.md
└── es
└── mi-artículo.md
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Translation | Django documentation
Translations in Django templates uses two template tags and a slightly different syntax than in Python code. To give your template access to...
Read more >How do you translate the slug value of a page? - Stack Overflow
It has been long but I'm going to post an answer anyway, the best way to get rid of the different slugs problem...
Read more >i18n in model fields - FuelPHP forums
My first idea is to store each fields that require translations in another table, category_lang (with fields id, lang, slug, label, summary, details),...
Read more >Gatsby i18n: A Hands-on Guide | Phrase
Note the slug field in the front matter, as we'll use it for our dynamic routing in a minute. blog/courage-after-greatness/index.mdx.
Read more >Multilingual slug setup - Craft CMS Stack Exchange
For a multi locale setup with translated slugs it's recommended to not rely on "URI to template matching" at all and create an...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
any news on this topic? I really like the i18n feature, but the fact that files are always saved in the default language makes it very hard to use, when the goal is to have translated urls in the end.
could help out if needed, would love to see the feature in near future
Sorry for the delays, after having a hand at this, this seems a bit trickier to accomplish than it seems.
What we want to have is for the user to be able to visit ether:
site.com/en/english
site.com/es/espanol
with their respective
.md
filesitems/en/english.md
items/es/espanol.md
at the moment we store the
.md
files as:items/en/english.md
items/es/english.md
this is because when you initially create the record on the admin panel, the slug is
english
(for the main locale) and when you want to re-edit the record as an admin you need to re-navigate to the/edit/english
The problem is not being able to change the created files, the problem is finding them again on the admin side.
if the files are stored as
items/en/english.md
items/es/espanol.md
they show up as a single item on the ui, under the
english
slug. Because actual translation isn’t performed I don’t see how we can find theitems/es/espanol.md
record based onenglish
slug.items/<id>/<locale>/<slug>.md
, so admin can edit on/admin/<id>
, and for the user when we query we flatten out the <id> folder as if it doesn’t exist.items/<locale>/<id>;<slug>.md
but seems like less change.