File tree Expand file tree Collapse file tree 3 files changed +57
-0
lines changed
Expand file tree Collapse file tree 3 files changed +57
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Custom Cleaner
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ pull_request :
8+ branches :
9+ - main
10+
11+ jobs :
12+ run-python-script :
13+ runs-on : ubuntu-latest
14+ steps :
15+ - name : Checkout repository
16+ uses : actions/checkout@v4
17+
18+ - name : Set up Python
19+ uses : actions/setup-python@v4
20+ with :
21+ python-version : ' 3.x'
22+
23+ - name : Install dependencies
24+ run : |
25+ python -m pip install --upgrade pip
26+
27+ - name : Run cleaner.py
28+ run : python ./cleaner.py
Original file line number Diff line number Diff line change @@ -91,3 +91,11 @@ In definitiva per partecipare a questo progetto bisogna:
91911 . Creare un fork
92922 . Effettua le modifiche
93933 . Richiedi di integrare il tuo lavoro tramite pull request
94+
95+ ## Workflows
96+ Abbiamo due workflow sulla repository:
97+
98+ - Validate: controlla che l'XML sia valido
99+ - Cleaner: rimuove ogni personalizzazione di traduzione, rimuovendo i ` <phrase> ` con ` addon_id="" `
100+
101+ Non è necessaria alcuna operazione, i workflow vengono eseguiti automaticamente alla PR e alla Push
Original file line number Diff line number Diff line change 1+ import xml .etree .ElementTree as ET
2+
3+ def remove_empty_phrases (xml_file ):
4+ # Carica il file XML
5+ tree = ET .parse (xml_file )
6+ root = tree .getroot ()
7+
8+ # Trova tutti i genitori che hanno una tag <phrase> con addon_id="" e rimuove tali <phrase>
9+ phrases_to_remove = root .findall (".//phrase[@addon_id='']" )
10+ for phrase in phrases_to_remove :
11+ for parent in root .iter ():
12+ if phrase in list (parent ):
13+ parent .remove (phrase )
14+
15+ # Salva il file XML modificato
16+ tree .write (xml_file , encoding = 'utf-8' , xml_declaration = True )
17+
18+ # Esempio di utilizzo
19+ if __name__ == "__main__" :
20+ xml_file = './language-italiano.xml'
21+ remove_empty_phrases (xml_file )
You can’t perform that action at this time.
0 commit comments