2

I want to save/serve multilingual data in my CMS application using Mongoose.

Is this the correct way?

name: {
    global: {
        type: String,
        default: '',
        trim: true,
        required: 'Please fill name',
    },
    en_US: String,
    tr_TR: String,
    sv_SE: String
}
  • 1
    How are you defining 'correct' here? Are you asking if that will work? Sure. – GrandmasterB May 5 '14 at 18:17
  • 3
    There is never a best way. Only the way which works best for you. – Philipp May 5 '14 at 18:31
  • A mongoose plugin can be great but I couldn't find any. Transmeta for Django do this very well. – Burak May 5 '14 at 19:04
3

I do not this that you have any "correct" or "bad" way, it is mostly based on your application design and requirements.

However, you may have noticed that in MongoDB 2.6.x the Full Text Search feature supports multi languages indexing and search if you specify a language in a document. This allow you to search text by language.

Documents look like:

{
_id: 1,
   language: "portuguese",
   original: "A sorte protege os audazes.",
   translation:
     [
        {
           language: "english",
           quote: "Fortune favors the bold."
        },
        {
           language: "spanish",
           quote: "La suerte protege a los audaces."
        }
    ]
}

for more informations:

http://docs.mongodb.org/manual/reference/text-search-languages/#text-search-languages

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.