This Python script automates the translation of .resx resource files for a project. It takes the base resource file (AppRes.resx), detects other language-specific .resx files in the same directory, and translates missing or outdated entries using Google Translate. It provides a menu-driven interface for user interaction or can be run with command-line arguments. Users can specify languages to exclude from translation.
- The script checks for
AppRes.resxin the given directory. - It iterates over all
.resxfiles, excluding specified languages. - It loads existing translations if available; otherwise, it creates a new
.resxfile. - It translates missing or outdated entries using Google Translate.
- The translated text is inserted into the respective
.resxfiles. - The script allows users to run it in interactive mode or via command-line arguments.
- Ensure Python 3 is installed:
sudo apt install python3
- Install dependencies:
pip install deep-translator
- Run the script:
python3 main.py --new-only --resx-directory /path/to/resx --exclude-languages "fr,de" - Create an executable:
pyinstaller --onefile --console --hidden-import=deep_translator.main main.py
- Ensure Python 3 is installed (download from Python website).
- Install dependencies:
pip install deep-translator
- Run the script:
python main.py --new-only --resx-directory C:\path\to\resx --exclude-languages "fr,de" - Create an executable:
pyinstaller --onefile --console --hidden-import=deep_translator.main main.py
- Ensure Python 3 is installed. You can use the official installer from Python website or Homebrew:
brew install python
- Install dependencies:
pip3 install deep-translator
- Run the script:
python3 main.py --new-only --resx-directory /path/to/resx --exclude-languages "fr,de" - Create an executable:
pyinstaller --onefile --console --hidden-import=deep_translator.main main.py
deep-translator(install usingpip install deep-translator)
--resx-directory <directory>: Specifies the path to the.resxfiles directory.--exclude-languages <languages>: Comma-separated list of languages to exclude (e.g.,fr,de).--force: Translates all entries regardless of existing values.- Example:
python main.py --force --resx-directory /path/to/resx --exclude-languages "es,it"
- Example:
--new-only: Translates only missing or new entries.- Example:
python main.py --new-only --resx-directory /path/to/resx --exclude-languages "fr,de"
- Example:
Ez a Python szkript automatikusan lefordítja a .resx erőforrásfájlokat egy projekt számára. Az alap AppRes.resx fájl alapján létrehozza vagy frissíti a többi nyelvi .resx fájlt a könyvtárban, és a hiányzó vagy elavult bejegyzéseket a Google Fordító segítségével lefordítja. Használható interaktív menüből vagy parancssori argumentumokkal. A felhasználók megadhatják a kizárni kívánt nyelveket.
- A szkript ellenőrzi az
AppRes.resxfájl létezését. - Bejárja az összes
.resxfájlt, kivéve a megadott nyelveket. - Betölti a meglévő fordításokat, vagy új
.resxfájlt hoz létre. - A hiányzó vagy elavult bejegyzéseket a Google Fordítóval lefordítja.
- A lefordított szövegeket beilleszti a megfelelő
.resxfájlokba. - A szkript interaktív menüből vagy parancssorból is futtatható.
- Telepítsd a Python 3-at:
sudo apt install python3
- Telepítsd a függőségeket:
pip install deep-translator
- Futtasd a szkriptet:
python3 main.py --new-only --resx-directory /path/to/resx --exclude-languages "fr,de" - Hozz létre egy futtatható fájlt:
pyinstaller --onefile --console --hidden-import=deep_translator.main main.py
- Telepítsd a Python 3-at (Python letöltés).
- Telepítsd a függőségeket:
pip install deep-translator
- Futtasd a szkriptet:
python main.py --new-only --resx-directory C:\path\to\resx --exclude-languages "fr,de" - Hozz létre egy futtatható fájlt:
pyinstaller --onefile --console --hidden-import=deep_translator.main main.py
- Telepítsd a Python 3-at. Használhatod a hivatalos telepítőt a Python letöltés oldalról, vagy a Homebrew-t:
brew install python
- Telepítsd a függőségeket:
pip3 install deep-translator
- Futtasd a szkriptet:
python3 main.py --new-only --resx-directory /path/to/resx --exclude-languages "fr,de" - Hozz létre egy futtatható fájlt:
pyinstaller --onefile --console --hidden-import=deep_translator.main main.py
deep-translator(telepíthetőpip install deep-translatorparanccsal)
--resx-directory <könyvtár>: Az.resxfájlokat tartalmazó könyvtár elérési útja.--exclude-languages <nyelvek>: Kizárt nyelvek vesszővel elválasztott listája (pl.fr,de).--force: Az összes bejegyzést lefordítja, még ha már léteznek is.- Példa:
python main.py --force --resx-directory /path/to/resx --exclude-languages "es,it"
- Példa:
--new-only: Csak az új vagy hiányzó bejegyzéseket fordítja le.- Példa:
python main.py --new-only --resx-directory /path/to/resx --exclude-languages "fr,de"
- Példa: