Translate common UI attributes in rendered HTML (best-effort). We only touch a small, safe set of attributes: - title - aria-label - placeholder We intentionally skip values that contain 'ButSystem' to keep the brand label unchanged.
(body: str, lang: str)
| 2863 | Args: |
| 2864 | s: Parameter. |
| 2865 | mapping: Parameter. |
| 2866 | |
| 2867 | Returns: |
| 2868 | Varies. |
| 2869 | """ |
| 2870 | def repl(m): |
| 2871 | """repl. |
| 2872 | |
| 2873 | Route handler or application helper. |
| 2874 | |
| 2875 | This docstring was expanded to make future maintenance easier. |
| 2876 | |
| 2877 | Args: |
| 2878 | m: Parameter. |
| 2879 | |
| 2880 | Returns: |
| 2881 | Varies. |
| 2882 | """ |
| 2883 | w = m.group(1) |
| 2884 | return mapping.get(w, w) |
| 2885 | return _WORD_RE.sub(repl, s) |
| 2886 | |
| 2887 | |
| 2888 | _SIMPLE_WORD_EN_RE = re.compile(r"^[A-Za-z0-9]+$") |
| 2889 | _SIMPLE_WORD_UNI_RE = re.compile(r"^[\w]+$", re.UNICODE) |
| 2890 | |
| 2891 | _EL_PHRASE_KEYS: List[str] = [] |
| 2892 | _EN_PHRASE_KEYS: List[str] = [] |
| 2893 | _EL_WORD_RE = None |
| 2894 | _EN_WORD_RE = None |
| 2895 | |
| 2896 | def _compile_safe_phrase_maps(): |
| 2897 | """Compile safe replacement helpers to avoid substring misspellings (e.g., Add -> Address).""" |
| 2898 | global _EL_PHRASE_KEYS, _EN_PHRASE_KEYS, _EL_WORD_RE, _EN_WORD_RE |
| 2899 | |
| 2900 | # English -> Greek |
| 2901 | el_word_keys = [k for k in TRANSLATIONS_EL.keys() if _SIMPLE_WORD_EN_RE.fullmatch(k or "")] |
no outgoing calls
no test coverage detected