npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

notion-translator

v0.0.7

Published

CLI tool to translate Notion pages into a different language by levergign DeepL's API

Downloads

23

Readme

Notion Translator

npm version

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:

  • Head to https://www.deepl.com/pro-api
  • Create either Free or Pro API account

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 Token
  • DEEPL_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