smart-translate 0.1.0__tar.gz → 0.1.1__tar.gz
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.
- {smart_translate-0.1.0 → smart_translate-0.1.1}/PKG-INFO +1 -1
- {smart_translate-0.1.0 → smart_translate-0.1.1}/pyproject.toml +1 -1
- smart_translate-0.1.1/smart_translate/rules.py +14 -0
- smart_translate-0.1.1/smart_translate/rules_loader.py +7 -0
- {smart_translate-0.1.0 → smart_translate-0.1.1}/smart_translate.egg-info/PKG-INFO +1 -1
- smart_translate-0.1.0/smart_translate/rules.py +0 -12
- smart_translate-0.1.0/smart_translate/rules_loader.py +0 -10
- {smart_translate-0.1.0 → smart_translate-0.1.1}/README.md +0 -0
- {smart_translate-0.1.0 → smart_translate-0.1.1}/setup.cfg +0 -0
- {smart_translate-0.1.0 → smart_translate-0.1.1}/smart_translate/__init__.py +0 -0
- {smart_translate-0.1.0 → smart_translate-0.1.1}/smart_translate/config.py +0 -0
- {smart_translate-0.1.0 → smart_translate-0.1.1}/smart_translate/protector.py +0 -0
- {smart_translate-0.1.0 → smart_translate-0.1.1}/smart_translate/rules/custom_rules.json +0 -0
- {smart_translate-0.1.0 → smart_translate-0.1.1}/smart_translate/translator.py +0 -0
- {smart_translate-0.1.0 → smart_translate-0.1.1}/smart_translate.egg-info/SOURCES.txt +0 -0
- {smart_translate-0.1.0 → smart_translate-0.1.1}/smart_translate.egg-info/dependency_links.txt +0 -0
- {smart_translate-0.1.0 → smart_translate-0.1.1}/smart_translate.egg-info/requires.txt +0 -0
- {smart_translate-0.1.0 → smart_translate-0.1.1}/smart_translate.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from .rules_loader import load_custom_rules
|
|
2
|
+
|
|
3
|
+
# Load rules ONCE at import time
|
|
4
|
+
CUSTOM_REPLACEMENTS = load_custom_rules()
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def apply_custom_rules(text, rules=None):
|
|
8
|
+
if rules is None:
|
|
9
|
+
rules = CUSTOM_REPLACEMENTS
|
|
10
|
+
|
|
11
|
+
for key, value in rules.items():
|
|
12
|
+
text = text.replace(key, value)
|
|
13
|
+
|
|
14
|
+
return text
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
from importlib import resources
|
|
2
|
-
import json
|
|
3
|
-
|
|
4
|
-
def load_custom_rules():
|
|
5
|
-
with resources.files("smart_translate.rules").joinpath("custom_rules.json").open("r") as f:
|
|
6
|
-
return json.load(f)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def apply_custom_rules(text, rules=CUSTOM_REPLACEMENTS):
|
|
10
|
-
for src, tgt in rules.items():
|
|
11
|
-
text = text.replace(src, tgt)
|
|
12
|
-
return text
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{smart_translate-0.1.0 → smart_translate-0.1.1}/smart_translate.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|