diff --git a/syncplay/messages2ass.py b/syncplay/messages2ass.py index 2d48291..801791f 100644 --- a/syncplay/messages2ass.py +++ b/syncplay/messages2ass.py @@ -1,19 +1,20 @@ # coding:utf8 # messages2ass.py, dictionary to subtitle exporter to automate translation +# version 2.0 # author sosie-js # 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__))) from pyonfx import * -# will include message_en.py a dictiatary of English messages for the syncplay gui -# https://raw.githubusercontent.com/Syncplay/syncplay/master/syncplay/messages_en.py -import messages_en +#choose your wished language target, a matching dict_message_file must be provided +lang="en" -dict_message_file="message_en" #.py +#------------------------------------------------------------ +dict_message_file="message_"+lang #.py 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("-------------------------------------------------------------------------------------") @@ -22,8 +23,20 @@ io = Ass() #Will use aegisub template Untitled.ass as basis instead of "in.ass" io.set_output(ass_message_file) meta, styles, lines = io.get_data() -#messages will hold the message dict -messages=messages_en.en +#include by string the messages file to convert to ass +# name=messages_. +#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) pos_time=0