mozilla/transonic — pull request #87 by chuckharmston (2014-12-17 23:01:11+00:00)
Title: Appropriately include or omit empty translations when submitting to the API (bug 1101263)

r? @ngokevin @spasovski @diox

We currently submit empty strings for every empty field, for every untranslated locale that transonic supports. This is a problem, because the API differentiates between empty strings and missing keys in translated fields (i.e. similar to how Django differentiates between `blank` and `null`.

This commit ensures that we only send complete sets of translations, and only then, for locales with a meaningful translation for each field.

Currently, if the user fills out a name and description in English but just a name in Dutch, it will send this data:

{
'name': {
'bn-BD': '',
'ca': '',
'others': '',
'en': 'Name',
'nl': 'Naam'
},
'description': {
'bn-BD': '',
'ca': '',
'others': '',
'en': 'Description',
'nl': ''
}
}

After this patch, it will only submit this:

{
'name': {
'en': 'Name',
'nl': 'Naam'
},
'description': {
'en': 'Description',
'nl': ''
}
}

There will be a companion commit to Zamboni that adds a management command to clean up the existing bad data.