MCPcopy Create free account
hub / github.com/dedsec1121fk/DedSec / _translate_common_attributes

Function _translate_common_attributes

Scripts/ButSystem.py:2865–2898  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

2863Args:
2864 s: Parameter.
2865 mapping: Parameter.
2866
2867Returns:
2868 Varies.
2869"""
2870 def repl(m):
2871 """repl.
2872
2873Route handler or application helper.
2874
2875This docstring was expanded to make future maintenance easier.
2876
2877Args:
2878 m: Parameter.
2879
2880Returns:
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
2896def _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 "")]

Callers 1

_translate_html_responseFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected