ClickHouse/docs/tools/translate.py

22 lines
507 B
Python
Raw Normal View History

2020-02-03 12:00:10 +00:00
#!/usr/bin/env python
from __future__ import print_function
import sys
import pprint
import googletrans
import pandocfilters
translator = googletrans.Translator()
def translate(key, value, format, _):
if key == 'Str':
print(value.encode('utf8'), file=sys.stderr)
return
[meta, contents] = value
cls = getattr(pandocfilters, key)
return cls(meta, translator.translate(contents, dest='es'))
if __name__ == "__main__":
pandocfilters.toJSONFilter(translate)