Translate the text, and the other part should call this method. :param text: text to translate :return: translated text
(self, text: str, ignore_cache: bool = False)
| 88 | self.cache.add_params(k, v) |
| 89 | |
| 90 | def translate(self, text: str, ignore_cache: bool = False) -> str: |
| 91 | """ |
| 92 | Translate the text, and the other part should call this method. |
| 93 | :param text: text to translate |
| 94 | :return: translated text |
| 95 | """ |
| 96 | if not (self.ignore_cache or ignore_cache): |
| 97 | cache = self.cache.get(text) |
| 98 | if cache is not None: |
| 99 | return cache |
| 100 | |
| 101 | translation = self.do_translate(text) |
| 102 | self.cache.set(text, translation) |
| 103 | return translation |
| 104 | |
| 105 | def do_translate(self, text: str) -> str: |
| 106 | """ |