Skip to content

Translated slugs between locales - linked translations via a reference property. Website with localized URL. #137

@CarloBu

Description

@CarloBu

Hello, I like sveltia cms a lot, in my opinion, sveltia cms is currently the best open source cms in the market.
I'm trying to find a solution for how to make localized markdown filenames work in sveltia cms. The post becomes quite long so I will structure it as readable as possible.

Description
I am currently working on localizing a website, I have done localization with the Astrolicious i18n tool, now I'm trying to work with Sveltia/Decap CMS. Despite extensive searches, I have not found a way to utilize translated filenames for the CMS content. I'm hoping to determine if it's feasible to make it work, I'm looking for any hacky solution as injecting a custom JavaScript into the CMS widget that allows searching for localized posts using translated filenames.

Current Implementation
For testing, I utilized the demo repository from the Astrolicious i18n tool and adapted it to my needs. Here are the relevant links:

GitHub Repository: astrolicious-i18n-demo
Live Demo: astrolicious-18n-demo.netlify.app

Currently, the testing CMS setup is as follows:

config.yaml

collections:
  - name: 'posts'
    label: 'Posts'
    folder: 'src/content/posts'
    create: true
    delete: true
    i18n: true
    format: yml
    extension: yaml
    editor:
      preview: false
    fields:
      - label: 'Default Locale Version'
        name: 'defaultLocaleVersion'
        widget: compute
        value: en/{{fields.title}}
      - label: 'Title'
        name: 'title'
        widget: 'string'
        i18n: true

Objective
My final goal is to create localized URLs based on slugs taken from Markdown filenames. For instance:

English URL: website/blog/english-post/
French URL: website/fr/le-blog/poste-francaise/
The i18n tool locates the localized YAML file by reading the defaultLocaleVersion, which points to the corresponding default locale file (en/english-post). That way i18n is able to generate localized routes.

Question
Is it possible to use some custom widget to enable sveltia cms locating for posts with localized filenames based on this reference?

I've managed to create a post with a default locale reference, but I'm still unable to create localized filenames directly in the CMS and "match" localized posts

Any insights or suggestions on how to implement this feature, or just tell that localized filenames are not possible, would be greatly appreciated.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions