Skip to content

Commit 076022d

Browse files
author
bram
committed
Added data class
1 parent ea6872d commit 076022d

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ dist/
44
*.egg-info/
55
__pycache__
66
build/
7-
db.sqlite3
7+
db.sqlite3
8+
.venv

python_gpt_po/po_translator.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import json
88
import logging
99
import os
10+
from dataclasses import dataclass
1011

1112
import polib
1213
from dotenv import load_dotenv
@@ -99,14 +100,14 @@ def update_po_entry(po_file, original_text, translated_text):
99100
logging.warning("Original text '%s' not found in the .po file.", original_text)
100101

101102

103+
@dataclass
102104
class TranslationConfig:
103105
""" Class to hold configuration parameters for the translation service. """
104-
def __init__(self, client, model, bulk_mode=False, fuzzy=False, folder_language=False): # pylint: disable=R0913
105-
self.client = client
106-
self.model = model
107-
self.bulk_mode = bulk_mode
108-
self.fuzzy = fuzzy
109-
self.folder_language = folder_language
106+
client: object
107+
model: str
108+
bulk_mode: bool = False
109+
fuzzy: bool = False
110+
folder_language: bool = False
110111

111112

112113
class TranslationService:
@@ -473,8 +474,14 @@ def main():
473474
else:
474475
detail_langs = [None] * len(lang_codes) # If no detailed language is provided, default to None
475476

476-
# Create a configuration object
477-
config = TranslationConfig(client, args.model, args.bulk, args.fuzzy, args.folder_language)
477+
# And in main():
478+
config = TranslationConfig(
479+
client=client,
480+
model=args.model,
481+
bulk_mode=args.bulk, # Changed bulk to bulk_mode
482+
fuzzy=args.fuzzy,
483+
folder_language=args.folder_language
484+
)
478485

479486
# Initialize the translation service with the configuration object
480487
translation_service = TranslationService(config, args.bulksize)

0 commit comments

Comments
 (0)