Save content files in multilanguage

Hello!

There is any way to save the multilanguage post with each language name?

Config

  i18n: {
    structure: "multiple_folders",
    locales: ["en", "es", "ca"],
    default_locale: "en",
  },

Current files

posts
 - en
   - image-optimization.md
 - es
   - image-optimization.md
 - ca
   - image-optimization.md

Expectation to get a language slug

posts
 - en
   - image-optimization.md
 - es
   - optimizacion-de-imagenes.md
 - ca
   - optimitzacio-de-imatges.md

You can find more about multi-language support here:

1 Like

I think that I can’t do it

This is the code for multilanguage files, and the slug es the slug for the default language :sob:

export function getFilePath(
  structure: I18N_STRUCTURE,
  extension: string,
  path: string,
  slug: string,
  locale: string,
) {
  switch (structure) {
    case I18N_STRUCTURE.MULTIPLE_FOLDERS:
      return path.replace(`/${slug}`, `/${locale}/${slug}`);
    case I18N_STRUCTURE.MULTIPLE_FILES:
      return path.replace(new RegExp(`${escapeRegExp(extension)}$`), `${locale}.${extension}`);
    case I18N_STRUCTURE.SINGLE_FILE:
    default:
      return path;
  }
}

Source

Thanks for circling back and sharing this, @nucliweb Sorry this isn’t the answer you were hoping for! If you are looking for additional places to brainstorm, feel free to check out the following resources:

netlify cms slack - join our friendly slack channel and chat with other cms pros to get the help you need.

GitHub Issues - think you’ve found a bug, or would like to make a feature request? Make your voice heard here. Netlify CMS is open source - PRs and other contributions are also welcome!

Stack Overflow Check StackOverflow for questions tagged “Netlify CMS” if you don’t get an answer in the Slack or the GH issues. StackOverflow reaches a worldwide audience of knowledgeable people.

Your question will be left open here for anyone to comment - but we encourage you to check out the above resources if you are still looking for a solution!

1 Like