GithubHelp home page GithubHelp logo

fabasoad / translation-action Goto Github PK

View Code? Open in Web Editor NEW
36.0 2.0 5.0 11.49 MB

GitHub action that translates any text to any language supported by chosen provider.

License: MIT License

TypeScript 100.00%
github-actions github-action translation-action translation translate deepl-translator funtranslation-api google-translate libretranslate microsoft-translator

translation-action's Introduction

Translation action

Stand With Ukraine GitHub release (latest SemVer including pre-releases) unit-tests test-providers test-source security linting Maintainability Test Coverage Known Vulnerabilities

This action translates any text to any language supported by chosen provider. There is a list of providers that can be used for text translation. Please find more details for each provider below.

Contents

Inputs

Name Required Description Default Possible values
source Yes Can be text or path to the file for translation <Path>,<String>
provider Yes Provider identifier deepl, google, libretranslate, linguatools, microsoft, mymemory, funtranslations
api_key No API key that should be used for chosen provider "" <String>
api_additional_parameter No Additional parameter for the API. eg the region for Microsoft: canadacentral "" <String>
lang Yes The translation direction. Should be one of the option proposed by chosen provider <String>

Outputs

Name Required Description
text Yes Translated text

Providers

DeepL

  • Identifier is deepl.
  • Supported translation directions can be found here.
    • Be aware that source and target languages should be separated by - (hyphen) character while using them in lang input. For example, en-uk should be used in case you want to translate text from English into Ukrainian. See example below for more details.
  • How to get API key:
    • Sign up to DeepL (free plan is fine).
    • Go to Account -> Account -> Authentication Key for DeepL API section

Example of translating "Love" word from English into Ukrainian:

jobs:
  deepl:
    name: DeepL
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: fabasoad/translation-action@main
        id: deepl-step
        with:
          provider: deepl
          lang: en-uk
          source: Love
          api_key: ${{ secrets.DEEPL_API_KEY }}
      - name: Print the result
        run: echo "Translation is '${{ steps.deepl-step.outputs.text }}'"
        shell: sh

Output is the following:

> echo "Translation is 'Любов'"
Translation is 'Любов'

Google

  • Identifier is google.
  • Supported translation directions can be found here.
    • Be aware that source and target languages should be separated by - (hyphen) character while using them in lang input. For example, ms-en should be used in case you want to translate text from Malay into English. See example below for more details.

Example of translating "Victory" word from Malay into English:

jobs:
  google:
    name: Google
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: fabasoad/translation-action@main
        id: google-step
        with:
          provider: google
          lang: ms-en
          source: Kemenangan
      - name: Print the result
        run: echo "Translation is '${{ steps.google-step.outputs.text }}'"
        shell: sh

Output is the following:

> echo "Translation is 'Victory'"
Translation is 'Victory'

LibreTranslate

  • Identifier is libretranslate.
  • Supported translation directions can be found here.
    • Be aware that source and target languages should be separated by - (hyphen) character while using them in lang input. For example, en-es should be used in case you want to translate text from English into Spanish. See example below for more details.
  • How to get API key:

Example of translating "Victory" word from English into Ukrainian:

jobs:
  libretranslate:
    name: LibreTranslate
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: fabasoad/translation-action@main
        id: libretranslate-step
        with:
          provider: libretranslate
          lang: en-uk
          source: Victory
          api_key: ${{ secrets.LIBRETRANSLATE_API_KEY }}
      - name: Print the result
        run: echo "Translation is '${{ steps.libretranslate-step.outputs.text }}'"
        shell: sh

Output is the following:

> echo "Translation is 'Перемога'"
Translation is 'Перемога'

Linguatools

  • Identifier is linguatools. API Key is not needed for this provider.
  • Supported translation directions:
"de-en","de-es","de-nl","de-pl","de-it","de-cs","en-de","es-de","nl-de","pl-de","it-de","cs-de"

Microsoft

  • Identifier is microsoft.
  • Supported translation directions:
"af","ar","bg","bn","bs","ca","cs","cy","da","de","el","en","es","et","fa","fi","fr","he","hi","hr","ht","hu","id","is","it","ja","ko","lt","lv","ms","mt","mww","nb","nl","pl","pt","ro","ru","sk","sl","sr-Latn","sv","sw","ta","th","tlh-Latn","tr","uk","ur","vi","zh-Hans"
  • How to get API key:

Please follow the steps described in this article.

You will also need to provide the region of the key using the api_additional_parameter, e.g.:

with:
  api_additional_parameter: canadacentral

MyMemory

  • Identifier is mymemory.
  • Supported translation directions:

Language direction should be separated by | character. For example, en|it (from English to Italian). More details here.

  • How to get API key:

API Key is optional. Visit Usage Limit Page to see the usage limit for free accounts. In case you want to use your API KEY, you should go to Registration Page and register a new account. Then go to API Key Generator Page and generate a new key.

FunTranslations

  • Identifier is funtranslations.
  • Supported translation directions:

from direction is English only at this moment, so lang parameter can be found here. Example:

- uses: fabasoad/translation-action@main
  with:
    provider: funtranslations
    lang: 'klingon'
    source: 'Who are you'

translation-action's People

Contributors

baywet avatar dependabot[bot] avatar fabasoad avatar github-actions[bot] avatar pre-commit-ci[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

translation-action's Issues

Add "Klingon" provider

Is your feature request related to a problem? Please describe.
Just a new provider to the supported list.

Describe the solution you'd like
I want to have a possibility to translate text using klingon provider.

Describe alternatives you've considered
Any other provider from supported providers list.

Additional context
List of possible providers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.