kontent-ai / model-generator-js

MIT License
13 stars 9 forks source link

Changes languages in project structure to array #17

Closed ondrabus closed 2 years ago

ondrabus commented 2 years ago

Motivation

Language codenames may contain characters that are not valid when used as JSON keys. Typically, it's the ISO representations of languages:

And others. The generated project structure used language codenames as object keys which led to invalid JSON project structure:

export const projectModel = {
  languages: {
    cs-CZ: {
      codename: 'cs-CZ',
      name: 'Czech',
    },
    en-US: {
      codename: 'en-US',
      name: 'Default project language',
    },
  },

This PR adjusts the languages part of project structure to array - easily filterable using Array.find by the codename property.

Enngage commented 2 years ago

Thank you for the PR and sorry I have to close it again :) I believe we should keep the languages strongly typed just like content types & taxonomies as there are cases where you could benefit from it. You can always convert object to array via the object.values method