nidhal baccouri commited on
Commit
a0092fa
·
1 Parent(s): 1bfffaa

added class properties for reusability

Browse files
deep_translator/base.py CHANGED
@@ -42,6 +42,22 @@ class BaseTranslator(ABC):
42
  self.payload_key = payload_key
43
  super().__init__()
44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  def _type(self):
46
  return self.__class__.__name__
47
 
 
42
  self.payload_key = payload_key
43
  super().__init__()
44
 
45
+ @property
46
+ def source(self):
47
+ return self._source
48
+
49
+ @source.setter
50
+ def source(self, lang):
51
+ self._source = lang
52
+
53
+ @property
54
+ def target(self):
55
+ return self._target
56
+
57
+ @target.setter
58
+ def target(self, lang):
59
+ self._target = lang
60
+
61
  def _type(self):
62
  return self.__class__.__name__
63
 
deep_translator/google.py CHANGED
@@ -118,5 +118,8 @@ class GoogleTranslator(BaseTranslator):
118
 
119
 
120
  if __name__ == "__main__":
121
- t = GoogleTranslator().translate("hallo welt")
122
- print("translation: ", t)
 
 
 
 
118
 
119
 
120
  if __name__ == "__main__":
121
+ trans = GoogleTranslator(source='auto', target='de')
122
+ res = trans.translate("cute")
123
+ print("translation: ", res)
124
+ trans.target = "fr"
125
+ print(f"changed target to: {trans.target} => translation changed: {trans.translate('cute')}")