-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTranslatorViewMaker.py
More file actions
39 lines (38 loc) · 1.66 KB
/
Copy pathTranslatorViewMaker.py
File metadata and controls
39 lines (38 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#imports
import configparser
from io import StringIO
#preperations
parser = configparser.RawConfigParser(delimiters=('='),default_section=(' '))
parser.optionxform = lambda option: option
string = StringIO()
print("Before running this program make sure to run a duplicate checker on your .ini using Ksempac's Translation Toolkit")
print("Also make sure that the ini file is inside the same folder as the program because I'm lazy (it will be fixed)")
source = input("Please enter your .ini file name here, preferebly en.ini: ")
theme = input("Please type you theme name (for your reference, you can even leave it blank):")
print('Select the type of view:')
print("1.Show the line's section and value in the file")
print("2.show the line's line number in the file")
choice = input()
parser.read(source, encoding="utf-8")
#where the magic happens
for parser.sections in parser:
section = parser.sections
print('[',section,']',sep='')
for key in parser[section]:
if choice == '1':
line = theme, section, key
parser.set(section, key, line)
print(key, '=', line)
else:
line_num = 0
line_source = open(source, "r", encoding="utf-8")
for number, line in enumerate(line_source):
if key in line:
line_num = number + 1
break
line = theme, line_num
parser.set(section, key, line)
print(key, '=', line)
with open('tr.ini', "w", encoding="utf-8") as target:
parser.write(target)
input("Done! Your tr.ini is ready to be used, press ENTER to exit")