I’m looking for any opensource implementation of the multilingual StringField for MongoEngine.
I can do it by myself but if there is one I think it is better to use it and contribute to it may be.
What I want is the field that will know about various values of the same property in several languages, e.g.
class MyDoc(Document):
name = MultilingualString()
my_doc = MyDoc.objects.first()
# storing value
my_doc.name.en = 'My Document'
# outputs stored value 'Mein Dokument'
print(my_doc.name.de)
I think it is pretty easy to implement such field using DictField internally.
P.S.: yes, it is really similar to the MongoKit’s way.
Here it is for now.
“mongoengine-multilingual-field” project
Usage:
Here is what it looks like in MongoDB:
It allows to define effective index by
(value, lang)for fast value search and uses normalized locale names as lang codes.