How to translate models in Sails.js?

余生颓废 提交于 2019-12-04 19:54:58

You can do it 2 ways:

1.) Duplicate the fields in you model for each language like:

{
  title_en: "string",
  title_fr: "string", 
}

2.) You can add a "language"-attribute to your Articles (so you can select find().where({lang: 'en'}):

{
  title: "string",
  lang: {
     type: "string",
     enum: ["en","fr"]
  }
}

What way to choose depends on your usecase.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!