diff options
| author | AlexanderCurl <alexc@alexc.hu> | 2026-04-18 17:46:06 +0100 |
|---|---|---|
| committer | AlexanderCurl <alexc@alexc.hu> | 2026-04-18 17:46:06 +0100 |
| commit | 70ca3fef77ee8bdc6e3ac28589a6fa08c024cc69 (patch) | |
| tree | ab1123d4067c1b086dd6faa7ee4ea643236b565a /raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/translations/replace_qstr.py | |
| parent | 5d94c0a7d44a2255b81815a52a7056a94a39842d (diff) | |
| download | RaveOS-PKGBUILD-70ca3fef77ee8bdc6e3ac28589a6fa08c024cc69.tar.gz RaveOS-PKGBUILD-70ca3fef77ee8bdc6e3ac28589a6fa08c024cc69.zip | |
Replaced file structures for themes in the correct format
Diffstat (limited to 'raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/translations/replace_qstr.py')
| -rwxr-xr-x | raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/translations/replace_qstr.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/translations/replace_qstr.py b/raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/translations/replace_qstr.py new file mode 100755 index 0000000..b1ae17e --- /dev/null +++ b/raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/translations/replace_qstr.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 +import os +import re +from pathlib import Path + +def replace_qstr_in_file(file_path, root_dir): + with open(file_path, 'r', encoding='utf-8') as f: + content = f.read() + + original_content = content + relative_path = file_path.relative_to(root_dir) + + qstr_pattern = re.compile(r'qsTr\("([^"]+)"\)') + + def replacement(match): + term = match.group(1) + context = term + return f'I18n.tr("{term}", "{context}")' + + content = qstr_pattern.sub(replacement, content) + + if content != original_content: + with open(file_path, 'w', encoding='utf-8') as f: + f.write(content) + return True + return False + +def main(): + script_dir = Path(__file__).parent + root_dir = script_dir.parent + + modified_count = 0 + + for qml_file in root_dir.rglob('*.qml'): + if 'translations' in str(qml_file): + continue + + try: + if replace_qstr_in_file(qml_file, root_dir): + modified_count += 1 + print(f"Modified: {qml_file.relative_to(root_dir)}") + except Exception as e: + print(f"Error processing {qml_file}: {e}") + + print(f"\nTotal files modified: {modified_count}") + +if __name__ == '__main__': + main() |