Skip to content

Commit e39aaf1

Browse files
committed
[FIX] fixing TranslationConfig's docs_dir property - appling dynamic class property
1 parent 8b5e4b0 commit e39aaf1

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

scripts/translate.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,24 @@ class TranslationConfig:
3838
target_langs: List[str] = field(
3939
default_factory=lambda: ["ko", "ja", "zh", "es", "fr", "de"]
4040
)
41-
docs_dir: Path = Path(__file__).parent.parent / "docs" / source_lang
42-
api_provider: str = "openai" # openai, anthropic, etc.
41+
_docs_dir: Optional[Path] = field(default=None, repr=False)
42+
api_provider: str = "openai"
4343
api_key: Optional[str] = None
4444
create_pr: bool = True
4545
branch_prefix: str = "translation"
4646

47+
@property
48+
def docs_dir(self) -> Path:
49+
"""Get docs directory path."""
50+
if self._docs_dir is None:
51+
return Path(__file__).parent.parent / "docs" / self.source_lang
52+
return self._docs_dir
53+
54+
@docs_dir.setter
55+
def docs_dir(self, value: Path) -> None:
56+
"""Set docs directory path."""
57+
self._docs_dir = value
58+
4759

4860
class TranslationAPI:
4961
"""Base class for translation API providers."""

0 commit comments

Comments
 (0)