I created a Python script that automatically translates my Qiita articles and posts them to Qiita / gist / Twitter

**This article is an automatic translation of the article[f1c47ab15c17d873fd03] below.
https://qiita.com/speaktech/items/f1c47ab15c17d873fd03**

# transQiita (made)
transQiita is a command line application using Qiita API v2 and googletrans. ** You can automatically translate articles on Qiita into English and post them to Qiita interactively (or non-interactively) by executing from the command line.
Also, you can post to gist/Twitter at the same time by using Qiita's GitHub linkage and Twitter linkage (optional).

** GitHub repository: ** [tm-tech/transQiita] (https://github.com/tm-tech/transQiita)

## A quick demo!
[transQiita-demo.gif] (https://qiita-image-store.s3.amazonaws.com/0/218139/60dc2dd6-9962-f1cd-732d-ea23a48db9b9.gif)

** Original article: **
https://qiita.com/speaktech/items/fa9dd70024865bff90f0
↓
** English translation articles posted automatically by script: **
https://qiita.com/speaktech/items/99d1530950987019e7d4

## Things necessary
-[googletrans] (https://pypi.org/project/googletrans/) (It seems that there is a bug causing malfunction as of 9/20, [this article] (https://qiita. The solution is presented at com/maboy/items/9a1336ece11db4630858))
-Qiita's access token (registered as environment variable QIITA_ACCESS_TOKEN, or specified directly as an option)

```
e.g.
$ pip install googletrans
$ export QIITA_ACCESS_TOKEN='YOUR QIITA ACCESS TOKEN'
```

## Example command line

```
$ python transQiita.py  [-h] [--gist] [--tweet] [--private] [--auto] [--token TOKEN]
```

## Optional arguments

```
-h, --help     ヘルプ
--gist         GitHub 連携していれば、gist へコードブロック部を投稿
--tweet        Twitter 連携していれば、投稿を Tweet
--private      記事を限定共有投稿
--auto         インタラクティブな実行をせず、自動実行（スケジュール実行時に利用）
--token TOKEN  環境変数を利用しない場合、Qiita のアクセストークンを指定
```

## Limitations
1. ** Code block part will not be translated, as indentation will be broken if code block part is translated. **
2. ** Since the translation process inserts a space between the symbol and the character, markdown decoration such as"**"or"~ ~"does not work. **

# Articles used for reference
-[I wrote a Python script that exports all my posts using Qiita API v2] (https://qiita.com/sta/items/5074df5fcb81d890897b)
-[A module that can use Google translation with python] (https://qiita.com/maboy/items/9a1336ece11db4630858)
-[A template for creating command line applications in Python] (https://qiita.com/Alice1017/items/0464a38ab335ac3b9336)

# Afterword
-**"Banner with original article ID"is added to the English translation as a mark so that update processing can be performed without using a database **.
When the original article is updated, the English translation article with the banner of the original article ID is found and updated.
You may manage the relationship between the original article and the English translation article in the database, but because I thought that preparing the database for that purpose would not be versatile, I aimed at a database-less design to make the code somewhat redundant. The
(Since it was assumed to be used in regular batch processing, it did not matter if the processing would be somewhat heavy.)

-** I tried to fix it with a regular expression for a fatal restriction ** where the markdown collapses, but"*"is translated to"*"and the irregular decoration symbol appears Because, I was frustrated. (Thinking solutions)

-Last but not the least
** This is the first Python post for me at the infrastructure store. I think that there are many places where debugging is insufficient, so it would be appreciated if you could report any problems! ** (little voice)