Closed anbud closed 6 years ago
@anbud how/where are the translations saved?
Currently, it's very basic, it saves the translation files right back to i18n folder in the root of the project and merges it with existing translation files (to support partial translations). Now, that's the simplest approach. Of course, it takes care of the security aspect and data is sanitized before it's written to the file system. And if somebody tries to submit blank values for existing translations, they will be ignored.
I also had in mind that we could save translations in the database first and that they can be merged with existing translations when moderators decide whether it's good or not. But that could be a new issue.
OK.
The problem with that is that in production everything is pulled from master and rebuild for node. So no changes made on production will survive.
I haven't looked at the i8n package, how hard would it be to fetch translations straight from mongo instead of the file system?
Oh, that is a problem.
Well, I've just did a little bit of research, there are two possible solutions here then:
What do you think? Both solutions aren't that hard to implement and they're almost equal complication-wise.
Hmmm, since they are basically both the same amount of effort, it's probably better to go with 2 so that when we start getting serious traffic it removes a tiny amount of mongodb bottleneck if there are multiple nodejs instances. It's also probably more of a C4ish way to do it.
You're right, it is a little bit more c4ish. Ok, that's how I'll do it, I'll send a PR later today. :)
Solution: Automatically generate translation forms based on the translation scope and missing translation keys and allow users to easily enter new translation data. Save data directly to a json file so it's instatly ready for use.