-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#Build command: "C:\Program Files (x86)\Python36-32\Scripts\pyinstaller" "D:\Dokumente\_Git\WowsRename\rename.py" --onefile --icon=wows.ico | ||
import os | ||
import sys | ||
import polib | ||
import glob | ||
|
||
cur_path = os.path.dirname(os.path.realpath(__file__))+"/" | ||
#print("Working in:", cur_path) | ||
|
||
path = "" | ||
mo_files = glob.glob(cur_path+"*.mo") | ||
for mo in mo_files: | ||
if("global.mo" in mo): | ||
path = mo | ||
|
||
input("WARNING - Make a copy of your .mo file first. Press Enter to continue.") | ||
print() | ||
if(path == ""): | ||
print("You need to locate your language file in your install folder.") | ||
print("The path looks something like this:") | ||
print("C:/Program Files/WOWS/res/texts/en/LC_MESSAGES/global.mo") | ||
path = input("Enter the path of you .mo file: ") | ||
|
||
print() | ||
replaceA = input("Enter the name / string that should be replaced (e.g 'Yamato'): ") | ||
replaceB = input("Enter the name / string that it should be replaced with (e.g 'Tomato'): ") | ||
|
||
print("Working...") | ||
if(path==""): | ||
mo_file = polib.mofile(mo_files[0]) | ||
else: | ||
mo_file = polib.mofile(path) | ||
|
||
replaced = 0 | ||
print("-------------------------------------------------------------") | ||
for line in mo_file: | ||
line.msgid_with_context = line.msgid #somehow needed to save the file (not sure what it does) | ||
if(replaceA in line.msgstr): | ||
replaced +=1 | ||
line.msgstr = line.msgstr.replace(replaceA, replaceB) | ||
print(line.msgstr) | ||
print("-------------------------------------------------------------") | ||
|
||
print("Replaced "+str(replaced)+" entries") | ||
print("Saving file...") | ||
mo_file.save(path) | ||
print("Done!") |