decaporg / decaporg/decap-cms

Use i18n translated fields in slug template tags

Open
#5,493 7 comments 5 reactions 0 assignees View on GitHub
area: i18n type: feature
Dominant language
JavaScript
Stars
19.4k
Forks
3.1k
Avg merge
1d 14h
Merged PRs (30d)
9

Description

**Context**
- i18n support:
- https://www.netlifycms.org/docs/beta-features/#i18n-support
- Slug template tags
- https://www.netlifycms.org/docs/configuration-options/#slug

**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
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.