Giter Club home page Giter Club logo

translate-readme's Introduction

Translate Readme Action

README Translation

GitHub Action to translate Readme to any language

This is a GitHub Action that automatically translate the readme in your repo to a specified language.

A submission for the DEV: GitHub Actions For Open Source! hackathon

Setup

  1. Add a workflow file to your project (e.g. .github/workflows/readme.yml):
name: Translate README

on:
  push:
    branches:
      - main
      - master
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Setup Node.js
        uses: actions/setup-node@v1
        with:
          node-version: 12.x
      # ISO Langusge Codes: https://cloud.google.com/translate/docs/languages  
      - name: Adding README - Chinese Simplified
        uses: dephraiim/translate-readme@main
        with:
          LANG: zh-CN
      - name: Adding README - Chinese Traditional
        uses: dephraiim/translate-readme@main
        with:
          LANG: zh-TW
      - name: Adding README - Hindi
        uses: dephraiim/translate-readme@main
        with:
          LANG: hi
      - name: Adding README - Arabic
        uses: dephraiim/translate-readme@main
        with:
          LANG: ar
      - name: Adding README - French
        uses: dephraiim/translate-readme@main
        with:
          LANG: fr

Configuration

Options

You can configure the action further with the following options:

  • LANG: The language you want to translate your readme to. The default is Simplified Chinese. (I'm a Ghanaian) The supported languages can be found below. (default: zh-CH) (required: false)

Supported Languages

Languages supported can be found here https://cloud.google.com/translate/docs/languages

Issues

Check here for issues related to this action.

Development

Suggestions and contributions are always welcome!

LICENSE

MIT

translate-readme's People

Contributors

benjaminchodroff avatar dependabot[bot] avatar ephraimduncan avatar github-actions[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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

translate-readme's Issues

Why did this mistake happen?

/home/runner/work/_actions/dephraiim/translate-readme/main/index.js:74
throw new Error(error);
^
Error: RequestError: The body, json and form options are mutually exclusive
at translateReadme (/home/runner/work/_actions/dephraiim/translate-readme/main/index.js:74:1)
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5)

Creating translations in given path

Is there any way of throwing the translations in a path described in the yml file? In my opinion having all these readmes in the root folder is a bit untidy.

Issues Related To Action

  • Supports only Markdown Syntax. HTML in Markdown Is Not Supported. (For Now)
  • I do not control the Translation API. It sometimes fails. In that case, please re-run your workflow job.
  • Creates another commit. In that case, you need to merge the local and remote repositories else you may face a lot of push and merge conflicts. git pull before git push

Projections

  • Add support for multiple languages. I removed it because I was facing a lot of conflict. Translations and the languages were being mixed up. 64612c9
  • Add a link in the main README file to link to the other translated README's. You can do this manually for now.

Push translated README to PR branch instead of `main`

@dephraiim thanks for this action, it works really well! I'm trying to use it in https://github.com/ultralytics/yolov5.

I tried to update my yaml to create translations directly in Pull Requests in ultralytics/yolov5#10445, but was unable to do so. Do you know if it's possible to do this? Use case would be for translated READMEs to form part of a larger PR, which is a little cleaner than being recorded as a separate commit to master.

The yaml I tried for this is here:

name: Translate README

on:
  pull_request:
    branches:
      - main
      - master
    paths:
      - README.md
    
jobs:
  Translate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: 16
      # ISO Langusge Codes: https://cloud.google.com/translate/docs/languages  
      - name: Adding README - Chinese Simplified
        uses: dephraiim/translate-readme@main
        with:
          LANG: zh-CN

And this is the error I get is

(node:1711) UnhandledPromiseRejectionWarning: Error: Error: fatal: You are not currently on a branch.

Screenshot 2022-12-08 at 16 41 17

@AyushExel

Issue with , (comma) symbol not adding a space

When i translate with this action, the , (comma) doesn't get a space even if it already had a space. I will show an example:
image
You will see that the comma has no space. Fix this to make this look good.

fatal: unable to access: The requested URL returned error: 403

image

I see the following error in Jobs in Actions tabs:

Run dephraiim/translate-readme@main with: LANG: zh-CN AST CREATED AND READ README.zh-CN.md written commit started finished commit (node:1769) UnhandledPromiseRejectionWarning: Error: Error: Pushing to https://github.com/BlueSpaceTeam/[2](https://github.com/BlueSpaceTeam/2048-react/runs/6892960790?check_suite_focus=true#step:4:2)048-react remote: Permission to BlueSpaceTeam/2048-react.git denied to github-actions[bot]. fatal: unable to access 'https://github.com/BlueSpaceTeam/2048-react/': The requested URL returned error: 40[3](https://github.com/BlueSpaceTeam/2048-react/runs/6892960790?check_suite_focus=true#step:4:3) at translateReadme (/home/runner/work/_actions/dephraiim/translate-readme/main/index.js:7[4](https://github.com/BlueSpaceTeam/2048-react/runs/6892960790?check_suite_focus=true#step:4:5):1) at processTicksAndRejections (internal/process/task_queues.js:97:[5](https://github.com/BlueSpaceTeam/2048-react/runs/6892960790?check_suite_focus=true#step:4:6)) (node:17[6](https://github.com/BlueSpaceTeam/2048-react/runs/6892960790?check_suite_focus=true#step:4:7)9) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2) (node:1[7](https://github.com/BlueSpaceTeam/2048-react/runs/6892960790?check_suite_focus=true#step:4:8)69) [DEP001[8](https://github.com/BlueSpaceTeam/2048-react/runs/6892960790?check_suite_focus=true#step:4:9)] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Selecting a translation also translates the list of languages

When experimenting with translating a README.md, I noted that selecting a translation (in this case, for zh-CN ... which I do not read ) the list of languages is ALSO translated. So if the user clicked on the wrong link and was not paying close attention, they might not be able to determine which link will get them back to another language.

It seems logical that each language's label in a menu of translations should always be shown in the native tongue for that menu item. English should always read as "English", french as "Française", simplified chinese as "简体中文]" Having a rollover hint in the translation language would be a nice added touch.

image

image

[Failed] Action failing to convert Long README.

Hello, there first thank you for this awesome tool.

What happened?

The action failed to convert the English version of Readme to all other versions except the first one in line which is the Chinese Simplified version.

What do you think happened?

I think since the README file was pretty big only the first version in line got converted all others simply resulted in failure.
readme file --> Nerd font's README

What makes you so sure?

I tried it again but this time removed the Chinese simplified and traditional from workflow only left with Hindi French and Arabic in the respective order. The result was that only the Hindi version(first in line) was successful and french and Arabic failed,

I have also tried it with small README files and the Action was successful.

Were you able to come up with any temporary/permanent solution?

The only temporary solution I was able to come up with is that creating separate YAML files for each conversion of the readme.
But it is not good as it creates a lot of unnecessary commits.

I Also tried putting timestamps between every job of 5min but that also did not work.

Logs

Only Hindi was successful
Log of the original workflow as copied from this repositories README

Node 12 actions are deprecated

I have encountered this error when trying to run the action for the first time:

Node.js 12 actions are deprecated. Please update the following actions to use Node.js 16: actions/checkout@v2, actions/setup- node@v1, dephraiim/translate-readme@main. For more information see: https://github.blog/changelog/2022-09-22- github-actions-all-actions-will-begin-running- on-node16-instead-of-node127.

As a momentary fix, I've forked the project and I've by changed Node's aforementioned actions to v3 and also edited action.yaml to use node16 instead of node12. With this changes it seems to work again, although I am not aware of possible changes in outcome due to the version change, as it's the first time I use this action.

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.