fix handling of documentTranslations and documentLocales

i think we need to do it this way to avoid losing data on partial flushes. and i think keeping knowledge of the current locale between flushes is also better.

if you agree you can merge this into your branch so it becomes visible in the PR to upstream.