[FIX] tools: use pot as reference file
In the first attempt at #26134, the pot_targets was cleared after creating the pot_rows object. Since the rows not present in the pot_targets are now skipped, clearing the pot should not be done. Still use a temporary list pot_rows to avoid modifying the list we are iterating on. Update the .po test file to match the new file format Closes #26881
This commit is contained in:
@@ -35,7 +35,7 @@ msgid "test.translation.import"
|
|||||||
msgstr "test.translation.import in french"
|
msgstr "test.translation.import in french"
|
||||||
|
|
||||||
#. module: test_translation_import
|
#. module: test_translation_import
|
||||||
#: help:test.translation.import,name:0
|
#: model:ir.model.fields,help:test_translation_import.field_test_translation_import__name
|
||||||
msgid "Efgh"
|
msgid "Efgh"
|
||||||
msgstr "Efgh in french"
|
msgstr "Efgh in french"
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ msgid "test.translation.import"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: test_translation_import
|
#. module: test_translation_import
|
||||||
#: help:test.translation.import,name:0
|
#: model:ir.model.fields,help:test_translation_import.field_test_translation_import__name
|
||||||
msgid "Efgh"
|
msgid "Efgh"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|||||||
@@ -1101,14 +1101,15 @@ def trans_load_data(cr, fileobj, fileformat, lang, lang_name=None, verbose=True,
|
|||||||
|
|
||||||
# discard the target from the POT targets.
|
# discard the target from the POT targets.
|
||||||
src = dic['src']
|
src = dic['src']
|
||||||
|
target_key = (dic['type'], dic['name'], dic['type'] != 'code' and dic['res_id'] or 0)
|
||||||
target = pot_targets.get(src)
|
target = pot_targets.get(src)
|
||||||
if not target or (dic['type'], dic['name'], dic['res_id']) not in target.targets:
|
if not target or target_key not in target.targets:
|
||||||
_logger.info("Translation '%s' (%s, %s, %s) not found in reference pot, skipping",
|
_logger.info("Translation '%s' (%s, %s, %s) not found in reference pot, skipping",
|
||||||
src[:60], dic['type'], dic['name'], dic['res_id'])
|
src[:60], dic['type'], dic['name'], dic['res_id'])
|
||||||
return
|
return
|
||||||
|
|
||||||
target.value = dic['value']
|
target.value = dic['value']
|
||||||
target.targets.discard((dic['type'], dic['name'], dic['type'] != 'code' and dic['res_id'] or 0))
|
target.targets.discard(target_key)
|
||||||
|
|
||||||
# This would skip terms that fail to specify a res_id
|
# This would skip terms that fail to specify a res_id
|
||||||
res_id = dic['res_id']
|
res_id = dic['res_id']
|
||||||
@@ -1143,7 +1144,6 @@ def trans_load_data(cr, fileobj, fileformat, lang, lang_name=None, verbose=True,
|
|||||||
if target.value:
|
if target.value:
|
||||||
for type, name, res_id in target.targets:
|
for type, name, res_id in target.targets:
|
||||||
pot_rows.append((type, name, res_id, src, target.value, target.comments))
|
pot_rows.append((type, name, res_id, src, target.value, target.comments))
|
||||||
pot_targets.clear()
|
|
||||||
for row in pot_rows:
|
for row in pot_rows:
|
||||||
process_row(row)
|
process_row(row)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user