@danhachuel/thunderbolt 0.4.86 → 0.4.87
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/hermes_ui/languages.py +6 -1
- package/package.json +1 -1
package/hermes_ui/languages.py
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import base64
|
|
6
|
+
import re
|
|
6
7
|
from functools import lru_cache
|
|
7
8
|
from typing import Any
|
|
8
9
|
|
|
@@ -1130,7 +1131,11 @@ def translate_ui_content(value: Any, language: Any = "pt") -> Any:
|
|
|
1130
1131
|
translated = value
|
|
1131
1132
|
for source, target in _sorted_translations(code):
|
|
1132
1133
|
if source != target and source in translated:
|
|
1133
|
-
|
|
1134
|
+
# Only replace complete tokens. This prevents the English token
|
|
1135
|
+
# ``Font`` from matching the Portuguese word ``Fonte`` and
|
|
1136
|
+
# producing malformed labels such as ``Fontee...``.
|
|
1137
|
+
pattern = rf"(?<!\w){re.escape(source)}(?!\w)"
|
|
1138
|
+
translated = re.sub(pattern, target, translated)
|
|
1134
1139
|
return translated
|
|
1135
1140
|
|
|
1136
1141
|
|
package/package.json
CHANGED