Skip to content

Commit

Permalink
defining an arg in the constructor might be easier than catching the …
Browse files Browse the repository at this point in the history
…error.
  • Loading branch information
frederik-uni committed Dec 1, 2024
1 parent 3b1870c commit d74ed22
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
17 changes: 7 additions & 10 deletions manga_translator/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,16 @@ async def dispatch(args: Namespace):
else: # batch
dest = args.dest
for path in natural_sort(args.input):
try :
# Apply pre-translation dictionaries
await translator.translate_path(path, dest, args_dict)
for textline in translator.textlines:
textline.text = translator.apply_dictionary(textline.text, pre_dict)
logger.info(f'Pre-translation dictionary applied: {textline.text}')
await translator.translate_path(path, dest, args_dict)
for textline in translator.textlines:
textline.text = apply_dictionary(textline.text, pre_dict)
logger.info(f'Pre-translation dictionary applied: {textline.text}')

# Apply post-translation dictionaries
for textline in translator.textlines:
textline.translation = translator.apply_dictionary(textline.translation, post_dict)
logger.info(f'Post-translation dictionary applied: {textline.translation}')
except Exception :
pass
for textline in translator.textlines:
textline.translation = apply_dictionary(textline.translation, post_dict)
logger.info(f'Post-translation dictionary applied: {textline.translation}')

elif args.mode == 'ws':
from manga_translator.mode.ws import MangaTranslatorWS
Expand Down
1 change: 1 addition & 0 deletions manga_translator/mode/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
class MangaTranslatorLocal(MangaTranslator):
def __init__(self, params: dict = None):
super().__init__(params)
self.textlines = []
self.attempts = params.get('attempts', None)
self.skip_no_text = params.get('skip_no_text', False)
self.text_output_file = params.get('text_output_file', None)
Expand Down

0 comments on commit d74ed22

Please sign in to comment.