Skip to content

Commit 68fe555

Browse files
committed
add lang_header parameter. lang_header can be used for specify the language for header values in excel/csv export (you can have _xml header values and _default values for submits datas). If not set, lang arg override lang_header arg value. Need this PR : kobotoolbox/formpack#215
1 parent 4b5abb6 commit 68fe555

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

kpi/models/import_export_task.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,12 @@ class ExportTask(ImportExportTask):
348348
response values. Specify `_xml` to use question and choice names
349349
instead of labels. Leave unset, or use `_default` for labels in
350350
the default language
351+
* `lang_header`: optional; the name of the translation to be used just for
352+
headers values. Specify `_xml` to use question names in headers
353+
instead of labels. Use `_default` for headers labels in the
354+
default language. Leave unset for override it and use lang arg
355+
value.
356+
Need this PR : https://github.com/kobotoolbox/formpack/pull/215
351357
* `hierarchy_in_labels`: optional; when `true`, include the labels for all
352358
ancestor groups in each field label, separated by
353359
`group_sep`. Defaults to `False`
@@ -462,10 +468,12 @@ def _build_export_options(self, pack):
462468
group_sep = self.data.get('group_sep', '/')
463469
translations = pack.available_translations
464470
lang = self.data.get('lang', None) or next(iter(translations), None)
471+
lang_header = self.data.get('lang_header', lang) or next(iter(translations), None)
465472
try:
466473
# If applicable, substitute the constants that formpack expects for
467474
# friendlier language strings used by the API
468475
lang = self.API_LANGUAGE_TO_FORMPACK_LANGUAGE[lang]
476+
lang_header = self.API_LANGUAGE_TO_FORMPACK_LANGUAGE[lang_header]
469477
except KeyError:
470478
pass
471479
tag_cols_for_header = self.data.get('tag_cols_for_header', ['hxl'])
@@ -478,6 +486,7 @@ def _build_export_options(self, pack):
478486
'copy_fields': self.COPY_FIELDS,
479487
'force_index': True,
480488
'tag_cols_for_header': tag_cols_for_header,
489+
'lang_header': lang_header,
481490
}
482491

483492
def _record_last_submission_time(self, submission_stream):

kpi/views/v1/export_task.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def create(self, request, *args, **kwargs):
5656
'lang',
5757
'hierarchy_in_labels',
5858
'fields_from_all_versions',
59+
'lang_header',
5960
)
6061
task_data = {}
6162
for opt in valid_options:

0 commit comments

Comments
 (0)