Skip to content

Commit

Permalink
Merge pull request #143 from nidhaloff/patch/class_properties
Browse files Browse the repository at this point in the history
Patch/class properties
  • Loading branch information
nidhaloff authored Mar 19, 2022
2 parents 1bfffaa + ec8e9cd commit c114ee0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
16 changes: 16 additions & 0 deletions deep_translator/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@ def __init__(
self.payload_key = payload_key
super().__init__()

@property
def source(self):
return self._source

@source.setter
def source(self, lang):
self._source = lang

@property
def target(self):
return self._target

@target.setter
def target(self, lang):
self._target = lang

def _type(self):
return self.__class__.__name__

Expand Down
7 changes: 5 additions & 2 deletions deep_translator/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,8 @@ def translate_batch(self, batch: List[str], **kwargs) -> List[str]:


if __name__ == "__main__":
t = GoogleTranslator().translate("hallo welt")
print("translation: ", t)
trans = GoogleTranslator(source='auto', target='de')
res = trans.translate("cute")
print("translation: ", res)
trans.target = "fr"
print(f"changed target to: {trans.target} => translation changed: {trans.translate('cute')}")
1 change: 1 addition & 0 deletions docs/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ The Translator++ mobile app
:width: 100
:alt: Icon of the app

You can download and try the app on play store https://play.google.com/store/apps/details?id=org.translator.translator&hl=en_US&gl=US

After developing the deep-translator, I realized how cool this would be if I can use it as an app on my mobile phone.
Sure, there is google translate, pons and linguee apps etc.. but isn't it cooler to make an app where all these
Expand Down

0 comments on commit c114ee0

Please sign in to comment.