def create_help_translation_jobs(input_dir, output_dir, install_subdir, template_file, language_files): translation_jobs = [] e_dir = os.path.join(input_dir, 'E') input_files = sorted(os.listdir(e_dir)) if not install_subdir: install_subdir = '' language_files_list = [] if len(language_files) > 0: language_files_list = language_files else: # We need at least one dummy language file to create any jobs language_files_list = [None] for language_file in language_files_list: output_translation_dir = None if language_file: output_translation_dir = nice_path_join( output_dir, language_file.language_char(), install_subdir) nice_mkdir(output_translation_dir) for input_file in input_files: translation_jobs.append( HelpTranslationJob(input_file=os.path.join(e_dir, input_file), output_file=nice_path_join( output_translation_dir, input_file), template_file=template_file, language_file=language_file)) return translation_jobs
def create_level_translation_jobs(input_dir, output_dir, template_file, language_files): translation_jobs = [] input_file = os.path.join(input_dir, 'scene.txt') translation_jobs.append(LevelTranslationJob( input_file = input_file, output_file = nice_path_join(output_dir, 'scene.txt'), template_file = template_file, language_files = language_files)) input_help_dir = os.path.join(input_dir, 'help') if os.path.isdir(input_help_dir): output_help_dir = nice_path_join(output_dir, 'help') nice_mkdir(output_help_dir) language_files_list = [] if len(language_files) > 0: language_files_list = language_files else: # We need at least one dummy language file to create any jobs language_files_list = [None] for language_file in language_files_list: for help_file in sorted(os.listdir(input_help_dir)): if language_file: translated_help_file = help_file.replace('.E.txt', '.{0}.txt'.format(language_file.language_char())) translation_jobs.append(HelpTranslationJob( input_file = os.path.join(input_help_dir, help_file), output_file = nice_path_join(output_help_dir, translated_help_file), template_file = template_file, language_file = language_file)) return translation_jobs
def preprocess_args(args): if not os.path.isdir(args.input_dir): sys.stderr.write('Expected existing input directory!\n') sys.exit(1) if not os.path.isdir(args.po_dir): sys.stderr.write('Expected existing translations directory!\n') sys.exit(1) if args.output_dir: nice_mkdir(args.output_dir)
def create_level_translation_jobs(input_dir, output_dir, template_file, language_files): translation_jobs = [] input_file = os.path.join(input_dir, "scene.txt") translation_jobs.append( LevelTranslationJob( input_file=input_file, output_file=nice_path_join(output_dir, "scene.txt"), template_file=template_file, language_files=language_files, ) ) input_help_dir = os.path.join(input_dir, "help") if os.path.isdir(input_help_dir): output_help_dir = nice_path_join(output_dir, "help") nice_mkdir(output_help_dir) language_files_list = [] if len(language_files) > 0: language_files_list = language_files else: # We need at least one dummy language file to create any jobs language_files_list = [None] for language_file in language_files_list: for help_file in sorted(os.listdir(input_help_dir)): if language_file: translated_help_file = help_file.replace(".E.txt", ".{0}.txt".format(language_file.language_char())) translation_jobs.append( HelpTranslationJob( input_file=os.path.join(input_help_dir, help_file), output_file=nice_path_join(output_help_dir, translated_help_file), template_file=template_file, language_file=language_file, ) ) return translation_jobs
def create_chaptertitles_translation_jobs(input_dir, output_dir, template_file, language_files): translation_jobs = [] for subdirectory in sorted(os.listdir(input_dir)): input_subdirectory = os.path.join(input_dir, subdirectory) if not os.path.isdir(input_subdirectory): continue input_file = os.path.join(input_subdirectory, 'chaptertitle.txt') if not os.path.isfile(input_file): continue output_subdirectory = nice_path_join(output_dir, subdirectory) nice_mkdir(output_subdirectory) translation_jobs.append(LevelTranslationJob( input_file = input_file, output_file = nice_path_join(output_subdirectory, 'chaptertitle.txt'), template_file = template_file, language_files = language_files)) return translation_jobs
def save_signalfile(signal_file_name): if signal_file_name: nice_mkdir(os.path.dirname(signal_file_name)) with open(signal_file_name, 'w') as signal_file: signal_file.close()