Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defining an arg in the constructor might be easier than catching the error #764

Merged
merged 1 commit into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading