32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
# services/translation/translation_factory.py
|
|
"""
|
|
Factory class for creating translation services
|
|
"""
|
|
from typing import Optional
|
|
from .google_translate import GoogleTranslateService
|
|
|
|
class TranslationFactory:
|
|
"""Factory class for creating translation service instances"""
|
|
|
|
@staticmethod
|
|
def create_service(service_type: str, **kwargs) -> Optional['TranslationService']:
|
|
"""
|
|
Create an instance of the specified translation service
|
|
|
|
Args:
|
|
service_type: Type of translation service ("google", etc.)
|
|
**kwargs: Additional arguments for service initialization
|
|
|
|
Returns:
|
|
TranslationService instance or None if service_type is not recognized
|
|
"""
|
|
services = {
|
|
"google": GoogleTranslateService,
|
|
# Add other translation services here
|
|
}
|
|
|
|
service_class = services.get(service_type.lower())
|
|
if service_class:
|
|
return service_class(**kwargs)
|
|
else:
|
|
raise ValueError(f"Unknown translation service type: {service_type}") |