diff --git a/src/ol_openedx_course_translations/ol_openedx_course_translations/utils/course_translations.py b/src/ol_openedx_course_translations/ol_openedx_course_translations/utils/course_translations.py index a77c802f..b492a79d 100644 --- a/src/ol_openedx_course_translations/ol_openedx_course_translations/utils/course_translations.py +++ b/src/ol_openedx_course_translations/ol_openedx_course_translations/utils/course_translations.py @@ -7,6 +7,7 @@ or attribute names """ +import ast import json import logging import re @@ -782,11 +783,16 @@ class _TranslationUnitRef: - "text": element.text - "tail": element.tail - "attr": element.attrib[attr_name] + - "dict_value": Value at json_path within a script tag (Python dict or JSON) + - "js_dict_value": Value at json_path within a JS variable in a script tag + - "js_dict_key": Key at json_path within a JS variable in a script tag """ kind: str xpath: str attr_name: str | None = None + json_path: tuple[str | int, ...] | None = None + js_var_name: str | None = None # For JS variable assignments class HtmlXmlTranslationHelper: @@ -802,6 +808,7 @@ class HtmlXmlTranslationHelper: * Translate `options` and `correct` attribute VALUES ONLY on * Never translate `correct` elsewhere * Never adds `display_name` (only translates it if present) + - Translates dictionary content within