Refactor flattening of arrays and records
Group all translations in a single function