Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow case_search_display and case_search_hint values to be translated in Transifex #34794

Merged
merged 5 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions corehq/apps/translations/app_translations/upload_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,10 @@ def _update_case_search_labels(self, rows):
properties = self.module.search_config.properties
displays = [row for row in self.condensed_rows if row['list_or_detail'] == 'case_search_display']
hints = [row for row in self.condensed_rows if row['list_or_detail'] == 'case_search_hint']
if len(displays) != len(hints) or len(displays) != len(properties):

if len(displays) != len(properties):
message = _(
Jtang-1 marked this conversation as resolved.
Show resolved Hide resolved
'Expected {expected_count} case_search_display and case_search_hint '
'properties in menu {index}, found {actual_label_count} for case_search_display and '
'{actual_hint_count} for case_search_hint'
Jtang-1 marked this conversation as resolved.
Show resolved Hide resolved
'Expected {expected_count} case_search_display '
'properties in menu {index}, found {actual_label_count} for case_search_display. '
Jtang-1 marked this conversation as resolved.
Show resolved Hide resolved
'No Case Search config properties for menu {index} were updated.'
).format(
expected_count=len(properties),
Expand All @@ -140,16 +138,26 @@ def _update_case_search_labels(self, rows):
self.msgs.append((messages.error, message))
continue
self._update_translation(display_row, prop.label)
for hint_row, prop in itertools.chain(zip(hints, properties)):
if hint_row.get('case_property') != prop.name:
message = _('A hint row for menu {index} has an unexpected case search property "{field}". '
'Case properties must appear in the same order as they do in the bulk '
'app translation download. No translations updated for this row.').format(
index=self.module.id + 1,
field=hint_row.get('case_property', ""))
self.msgs.append((messages.error, message))
continue
self._update_translation(hint_row, prop.hint)
if len(hints) == len(properties):
for hint_row, prop in itertools.chain(zip(hints, properties)):
if hint_row.get('case_property') != prop.name:
message = _('A hint row for menu {index} has an unexpected case search property "{field}".'
' Case properties must appear in the same order as they do in the bulk '
'app translation download. No translations updated for this row.').format(
index=self.module.id + 1,
field=hint_row.get('case_property', ""))
self.msgs.append((messages.error, message))
continue
self._update_translation(hint_row, prop.hint)
elif hints and len(hints) != len(properties):
Jtang-1 marked this conversation as resolved.
Show resolved Hide resolved
# Transifex translations don't include empty hint rows
Jtang-1 marked this conversation as resolved.
Show resolved Hide resolved
prop_index = -1
Jtang-1 marked this conversation as resolved.
Show resolved Hide resolved
for hint_row in hints:
while prop_index < len(properties):
prop_index += 1
if hint_row.get('case_property') == properties[prop_index].name:
self._update_translation(hint_row, properties[prop_index].hint)
break

def _update_report_module_rows(self, rows):
new_headers = [None for i in self.module.report_configs]
Expand Down
2 changes: 1 addition & 1 deletion corehq/apps/translations/integrations/transifex/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# Module or Form: sheet name for module/form: unique id
'module_and_forms_sheet': r'^(Module|Form):(\w+):(\w+)$', # maintain legacy module usage instead of menu
# case property: list/detail
'module_sheet': r'^(.+):(list|detail)$',
'module_sheet': r'^(.+):(list|detail|case_search_display|case_search_hint)$',
Jtang-1 marked this conversation as resolved.
Show resolved Hide resolved
}

TRANSIFEX_MODULE_RESOURCE_NAME = re.compile(r'^module_(\w+)(_v\d+)?$') # module_moduleUniqueID_v123
Expand Down
Loading