v2
This commit is contained in:
parent
9a02058547
commit
acfc3d5340
@ -1,19 +1,20 @@
|
|||||||
# coding:utf8
|
# coding:utf8
|
||||||
|
|
||||||
# messages2ass.py, dictionary to subtitle exporter to automate translation
|
# messages2ass.py, dictionary to subtitle exporter to automate translation
|
||||||
|
# version 2.0
|
||||||
# author sosie-js
|
# author sosie-js
|
||||||
# require my pythonfx mofied version adding fixes and del_line facility
|
# require my pythonfx mofied version adding fixes and del_line facility
|
||||||
#==========================================
|
#==========================================
|
||||||
|
|
||||||
# For relative imports to work
|
# For relative imports to work, ie use my local version of pythonfx
|
||||||
import os, sys; sys.path.append(os.path.dirname(os.path.realpath(__file__)))
|
import os, sys; sys.path.append(os.path.dirname(os.path.realpath(__file__)))
|
||||||
from pyonfx import *
|
from pyonfx import *
|
||||||
|
|
||||||
# will include message_en.py a dictiatary of English messages for the syncplay gui
|
#choose your wished language target, a matching dict_message_file must be provided
|
||||||
# https://raw.githubusercontent.com/Syncplay/syncplay/master/syncplay/messages_en.py
|
lang="en"
|
||||||
import messages_en
|
|
||||||
|
|
||||||
dict_message_file="message_en" #.py
|
#------------------------------------------------------------
|
||||||
|
dict_message_file="message_"+lang #.py
|
||||||
ass_message_file=dict_message_file+".ass"
|
ass_message_file=dict_message_file+".ass"
|
||||||
print("Welcome on the %s dictionary to ass file %s exporter" % (dict_message_file,ass_message_file) )
|
print("Welcome on the %s dictionary to ass file %s exporter" % (dict_message_file,ass_message_file) )
|
||||||
print("-------------------------------------------------------------------------------------")
|
print("-------------------------------------------------------------------------------------")
|
||||||
@ -22,8 +23,20 @@ io = Ass() #Will use aegisub template Untitled.ass as basis instead of "in.ass"
|
|||||||
io.set_output(ass_message_file)
|
io.set_output(ass_message_file)
|
||||||
meta, styles, lines = io.get_data()
|
meta, styles, lines = io.get_data()
|
||||||
|
|
||||||
#messages will hold the message dict
|
#include by string the <lang> messages file to convert to ass
|
||||||
messages=messages_en.en
|
# name=messages_<lang>.<lang>
|
||||||
|
#as lang is 'en', it will include message_en.py a dictionary of English messages for the syncplay gui
|
||||||
|
# https://raw.githubusercontent.com/Syncplay/syncplay/master/syncplay/messages_en.py
|
||||||
|
#equivalent to messages=messages_en.en
|
||||||
|
def my_import(name):
|
||||||
|
components = name.split('.')
|
||||||
|
mod = __import__(components[0])
|
||||||
|
for comp in components[1:]:
|
||||||
|
mod = getattr(mod, comp)
|
||||||
|
return mod
|
||||||
|
|
||||||
|
#messages will hold the ditionary of messages for the language lang
|
||||||
|
messages=my_import('messages_'+lang+'.'+lang)
|
||||||
i=len(lines)
|
i=len(lines)
|
||||||
pos_time=0
|
pos_time=0
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user