DeepL Translate Github Action
Tags: githubhack23, javascript, githubactions, github
Published: 2023-05-22 16:32:28

## What I built 

I created a [github action that translates text documents](https://github.com/lyqht/deepl-translate-github-action) into target languages that [DeepL](https://www.deepl.com/) supports. DeepL supports 32 languages at the moment.

DeepL is a AI translation service that uses deep learning techniques to translate entire sentences from one language to another, rather than translating words individually. It offers a rather generous free API for small translation volumes, so hobbyists like me and you 😉 or pretty much any open source project maintainer can try it out!

The GitHub action main script has been tested on simple text documents, as well as relatively complex text documents such as [Supabase's README.md](url) which contains many different symbols and html elements.

### Category Submission 

Maintainer Must-Haves

### App Link 

https://github.com/lyqht/deepl-translate-github-action

### Screenshots

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w512f3n6zhjo4b3zpmzw.png)

PR for screenshot can be found [here](https://github.com/lyqht/deepL-demo/pull/2)

I updated `original.md` here, and you can see the GitHub action generating a commit for the translated `ja.md` with very accurate translation.

### Description
This action uses the DeepL Translate API to translate text files in your repository to your target languages. The output will follow the file extension of the given input file.

### Link to Source Code
https://github.com/lyqht/deepl-translate-github-action 

### Permissive License
MIT

## Background (What made you decide to build this particular app? What inspired you?)

I've been thinking about accessibility, and they say pictures speak a thousand words, but sometimes we really should express ourselves through words. That makes alt text and semantic html structure important as focal points of accessibility for the general public. We can also include language in there, by making sure that text in a native language can easily be offered to the user that is viewing the content so they can enjoy it too.

While there are many plugins for i18n nowadays, the task of translating the text itself isn't trivial. Hence, I built this to allow easy translation of files in GitHub repositories using the DeepL API.

### How I built it (How did you utilize GitHub Actions or GitHub Codespaces? Did you learn something new along the way? Pick up a new skill?)

I have built 2 other GitHub actions before:
- [generate-supabase-db-types-github-action](https://github.com/lyqht/generate-supabase-db-types-github-action)
- [article-badge-counter-github-action](https://github.com/lyqht/article-badge-counter-github-action)

So the little experience I have does help me to build this project easier, but I still got to learn new stuff about the DeepL API stuff (both how cool/convenient it is and its limitations) and how to pass secret environment variables and inputs to the GitHub Action runner properly so that the file paths are parsed correctly.

I also tried GitHub Codespaces to create the project, it's pretty cool and easy to use.


![Preview of codespace in GitHub](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ij08tqomfb2b7xi2m0ee.png)

> The generated codespace was named after a birdie, how cute!


### Additional Resources/Info

For a demo, refer to this repository [deepl-demo](https://github.com/lyqht/deepl-demo)