Notion Translator
Notion Translator is a CLI tool that enables Notion users to translate Notion pages into a different language by leveraging the DeepL's text translation API.
You can install this tool just by running:
npm install -g notion-translator
How It Works
Let's say you'd like to translate a Notion page template written in English into a differen language such as Japanese, Spainish, and French. All you need to do with notion-translator are:
- Create a Notion internal integration and save its token as
NOTION_API_TOKEN
env variable - Create a DeepL API account and save its token as
DEEPL_API_TOKEN
env variable - Share the target Notion page with your Notion integration
- Run the following command to generate a translated page automatically
notion-translator \
--from en \
--to ja \
--url https://www.notion.so/acme/Blog-Post-ABC123
Live Demo
Once you create your integration for translation and set the Notion / DeepL credentials in env variables, you can run the command to translate with the Notion page URL:
When the translated page is ready, the CLI opens the page in the default web browser for you. The CLI generates the page as a child page of the original one, but you can move it anywhere else if you would like to do so!
Prerequisites
To run this CLI tool, the following are required:
Notion Internal Integration
You can configure your integration by the following steps:
- Head to https://www.notion.so/my-integrations
- Click "New integration" button
- Give an easy-to-understand name (e.g., Notion Translator) to the integration
- Make sure that you select Read content and Insert content in the Content Capabilities section
- Make sure that you select Read user information without email addresses in the User Capabilities section (if you are confident that all the pages that you want to translate do not have any user mentions, No user information works too)
- Click the Save button
Once the integration is created, you can find your Internal Integration Token under Secrets section. The string value should start with secret_
. You will use this value as NOTION_API_TOKEN
when configuring the CLI later.
DeepL API Account
You can configure your DeepL API account by the following steps:
Once your account is activated, you can find your DeepL API token on your account page. YOu will use this value as DEEPL_API_TOKEN
when configuring the CLI later.
Configure the CLI
You can install the CLI via npm
command.
npm install -g notion-translator
Let's hit notion-translator -h
to check if the command is now available for you.
$ notion-translator -h
Usage: notion-translator [options]
CLI to translate a Notion page to a different language
Options:
-u, --url <https://www.notion.so/...>
-f, --from <bg,cs,da,de,el,en,es,et,fi,fr,hu,id,it,ja,lt,lv,nl,pl,pt,ro,ru,sk,sl,sv,tr,zh>
-t, --to <bg,cs,da,de,el,en-gb,en-us,es,et,fi,fr,hu,id,it,ja,lt,lv,nl,pl,pt-pt,pt-br,ro,ru,sk,sl,sv,tr,zh>
-d, --debug
-h, --help display help for command
Prior to running the command, set two env variables:
NOTION_API_TOKEN
: Notion's Internal Integration TokenDEEPL_API_TOKEN
: DeepL's API token
If you prefer using .env
file, it also works as long as the file exists in the current directory.
Run the CLI Command
Please don't forget to share the original Notion page with your integration. You can find Share link at the top of a Notion page. From there, you can invite your Notion Translator integration to the page.
Okay, everything should be ready! Let's run the command now :)
notion-translator \
--from en \
--to ja \
--url https://www.notion.so/acme/Blog-Post-ABC123
If your credentails are not properly set, the CLI opens Notion / DeepL configuration page in the default browser for you. Double-check the settings and token string values.
Also, if you are unsure about the language code to pass as from/to languages, please refer to DeepL's official document.
I hope that this tool will help you save time!
Contributions
If you have any feedback or suggestions to this tool, please feel free to write in in this GitHub repository's issue tracker. Pull requests are welcome too!
License
The MIT License