Answer the question
In order to leave comments, you need to log in
All the same, how to work with multilingualism?
There have already been questions on this topic (including from me), but I would still like to finally clarify for myself and make a decision.
We have an application on node.js. express, mongodb and angular
To translate static information (the name of menu items, small text) everything is clear. We put angular-translate, connect the service, hang up the directive for switching languages, put json files in a folder and it works. Everything is simple.
What to do with the content in the database (form templates, some kind of dynamic content)? Let's say I need to make a form template in two languages. I am making a document
_id,
form_template:
ru : { title: 'поле'},
en : {title: 'field'}
...
, I save everything in it, but how do I output? Yes, and can use a different document scheme? Answer the question
In order to leave comments, you need to log in
Apply jQuery.
Contact the object.
$('body').append(data.contact_form_shortcode);
It is better to store all language versions in one place, or all on disk or all in the database. If you really need it in two or more places, if these templates change so much, then it’s better to take the base as the main place and synchronize it to disk when changes are made or upon request. You can generate these json files whenever you want. There are two options for how to store in the database, either there are many language versions inside one document / object or nearby, adding an indexed key. It depends on what data and what typical requests come to them, if there is little data and requests are rare, then there is no difference. For example, if there are 10 forms and each has 5 languages, and the forms change once a week, then it is more convenient to store all languages in forms and regenerate JSON on disk when changing. And if this is user-generated content that needs to be constantly served directly from the database, then take out the language identifier in the key with the index, so queries will be faster. And with a heavy load, it is better to cache language versions directly in the RAM on the server in order to give faster and less likely to go to the database for them.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question