diff options
| author | Nippy <nippy@rp1.hu> | 2026-05-08 19:50:49 +0200 |
|---|---|---|
| committer | Nippy <nippy@rp1.hu> | 2026-05-08 19:50:49 +0200 |
| commit | 3462bcc46ecf74f576ea4397f16492c16bd75b10 (patch) | |
| tree | c5ab7aef4498647e057bda8d49c11e5f9dda74c9 /raveos-hyprland-theme/theme-data/dms/translations/replace_qstr.py | |
| parent | 56616f693b4f263cbf0d47da43b67424efa6022d (diff) | |
| download | RaveOS-PKGBUILD-3462bcc46ecf74f576ea4397f16492c16bd75b10.tar.gz RaveOS-PKGBUILD-3462bcc46ecf74f576ea4397f16492c16bd75b10.zip | |
raveos update
Diffstat (limited to 'raveos-hyprland-theme/theme-data/dms/translations/replace_qstr.py')
| -rwxr-xr-x | raveos-hyprland-theme/theme-data/dms/translations/replace_qstr.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/raveos-hyprland-theme/theme-data/dms/translations/replace_qstr.py b/raveos-hyprland-theme/theme-data/dms/translations/replace_qstr.py new file mode 100755 index 0000000..b1ae17e --- /dev/null +++ b/raveos-hyprland-theme/theme-data/dms/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() |