I would suggest storing all translations in your mongoDb database, and then using the Express API, execute the query from the first page about translations.
[FRONT] ----> [Send mongoDB _id(s)] ---> [EXPRESS API] ===> [MONGOOSE] [FRONT] <---------- [Translations] <---- [EXPRESS API] <=== [MONGOOSE]
Mongoose Scheme
const Content = Schema({ // Type of item you are dealing with contentType: { type: String, enum: ['link', 'title', 'section', 'page'], }, // Value of translations translations: [{ languageName: String, value: String, }], // All Contents that are inside childs: [{ type: Schema.Types.ObjectId, ref: 'Content', }], });
Sample data (MongoDB document)
[{ _id: '00000000000000000000001', contentType: 'section', translations: [{ languageName: 'French', value: 'Section Enfant', }, { languageName: 'English', value: 'Child Section', }], dads: ['00000000000000000000002'], }, { _id: '00000000000000000000002', contentType: 'page', translations: [{ languageName: 'French', value: 'Page Baguette', }, { languageName: 'English', value: 'Tee Page', }], childs: [], }]
Example request: get all data about one random section
Content.find({ contentType: 'section', }) .then((ret) => { if (!ret) return []; // Here recursively get childs and childs and childs // until you got everything }) .then(() => {}) .catch(err => {});
Instruments
Mongoose
----> Mongoose queries
----> Mongoose Population
Express
PS : Here is the github project, which explains how to start the web / node project from (installation tools ... etc.) [Babel, Gulp, Webpack, ES6 ...]