kobotoolbox / kpi

kpi is the (frontend) server for KoboToolbox. It includes an API for users to access data and manage their forms, question library, sharing settings, create reports, and export data.
https://www.kobotoolbox.org
GNU Affero General Public License v3.0
133 stars 180 forks source link

When adding translations, `media::image` etc. columns in `choices` sheet are not updated and causing failures #2907

Open tinok opened 3 years ago

tinok commented 3 years ago

Description

When adding languages in the kpi UI, the media::xxx columns/fields in the choices sheet are not being "translated" updated to include the new language, leading to previews to fail, form downloads to fail, and not allowing users to translate these file names in the UI.

Steps to Reproduce

  1. Upload this form mediacolumns.xlsx

  2. Click on the Manage Translations (globe) button

  3. Set default language to English en and then add a translation French fr

  4. Edit the French translation (like so: image

  5. Click preview

  6. Open formbuilder

  7. Download XLSForm

Expected behavior

Step 3: File references salame.jpeg and cheese.jpeg appear in the translation list. Step 5: Preview succeeds. Step 6: Formbuilder opens. Step 7: Download succeeds

Actual behavior

Step 3:. File references for the two choice list images are not included in the translation screen. Step 5: Preview fails to open with error {"status":"failure","error_type":"ValueError","error":"('Incorrect translation count: \"media::image\"', {'label': ['Salame', None], 'list_name': 'pizza', 'media::image': ['salame.jpeg'], 'name': 'Salame'})","warnings":[]} Step 6: Formbuilder fails to open with error Step 7: Download fails with 500 server response

Additional details

Tested on HHI,du.

When deleting the media::image column in the choices sheet this issue goes away, so it's definitely the case that the media in the choices sheet isn't being included in kpi's translation method.

jnm commented 3 years ago

Related to #2629