xah icon

Create New TL

xah | PRO | 09/30/20 10:24:46 PM UTC (Edited) | 0 ⭐ | 470 👁️ | Never ⏰ | []
Python |

2 KB

|

None

|

0 👍

/

0 👎

def number(loop):
    if  loop < 10:
        loop = '0' + str(loop)
 
    else:
        loop = str(loop)
 
    return str(loop)
 
def newTL(name):
    
    file = open(name + '.txt', 'w')
    usuage = input('Usuage rights: ')
    email = input('Contact email: ')
    title = input('Chapter title: ')
    legend = input('Legend of notes: ')
    
    if usuage:
        file.write(usuage.upper())
 
    if email:
        file.write('\n(' + email + ')')
 
    file.write('\n\n')
 
    if title:
        file.write(title + '\n\n')
 
    if legend:
        legend = []
        note = input('Add note: ')
        while note:
            legend.append(note)
            note = input('Add another note: ')
        file.write('Legend of Notes:\n')
        for l in legend:
            file.write(l + '\n')
        file.write('\n\n')
 
    print('''Formatting done. Now starting translation formatting...
Begin new page by typing '-', blank page by typing '#', new panel by '/' and blank panels by typing '!'.
Press enter to end.''')
 
    text = input()
 
    pageNum = '01'
 
    while text:
        if text.startswith('-'):
            file.write('\npg' + pageNum)
            frameNum = '01'
            pageNum = number(pageNum)
        elif text.startswith('#'):
            pageNum = str(int(pageNum) + 1)
            continue
        elif text.startswith('/'):
            file.write('f' + frameNum + ': \t' + text[1:])
            frameNum = number(frameNum)
        elif text.startswith('!'):
            frameNum = str(int(frameNum) + 1)
            continue
        else:
            file.write('\t\t' + text)
        file.write('\n')
 
        text = input()
 
    print('Translation formatting is done. Would you like to write final comments?')
 
    comment = input()
 
    if comment:
        file.write('\n' + '{Comments: ' + comment + '}')
 
    file.close()
 
print('''To create new translation use newTL(name).
To ignore a certain section, press enter and nothing else!''')

Comments