Skip to content

GPT Translate by Input #118

GPT Translate by Input

GPT Translate by Input #118

name: GPT Translate by Input
on:
workflow_dispatch:
inputs:
path:
description: "The path to the directory containing the files to translate (e.g., docs/en/sql-reference/)"
required: true
default: "docs/en/sql-reference/"
permissions:
id-token: write
pull-requests: write
checks: write
statuses: write
contents: write
jobs:
gpt_translate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Delete all files in specified cn directory
run: |
TRANSLATION_DIR="${{ github.event.inputs.path }}"
CN_DIR=$(echo $TRANSLATION_DIR | sed 's/en/cn/')
echo "Deleting all files in $CN_DIR"
rm -rf $CN_DIR
echo "All files in $CN_DIR have been deleted."
git add .
- name: Get all files in specified directory
id: check_missing
run: |
TRANSLATION_DIR="${{ github.event.inputs.path }}"
echo "missing_md_files=$(find $TRANSLATION_DIR -type f \( -name '*.md' \) | sed -e 's/^/.\//' | tr '\n' ' ')" >> $GITHUB_OUTPUT
echo "missing_json_files=$(find $TRANSLATION_DIR -type f \( -name '*.json' \) | sed -e 's/^/.\//' | tr '\n' ' ')" >> $GITHUB_OUTPUT
- name: Log Missing Files
run: |
echo "Markdown Files Missing: ${{ steps.check_missing.outputs.missing_md_files }}"
echo "JSON Files Missing: ${{ steps.check_missing.outputs.missing_json_files }}"
- name: Run GPT Translate
uses: 3ru/[email protected]
with:
apikey: ${{ secrets.OPENAI_API_KEY }}
model: "deepseek-chat"
inputFiles: "${{ steps.check_missing.outputs.missing_md_files }}${{ steps.check_missing.outputs.missing_json_files }}"
outputFiles: "docs/cn/**/*.{md,json}"
languages: "Simplified-Chinese"
prompt: "You are a translation engine that has knowledge of databases and is familiar with SQL, HTML, Markdown and JSON syntax. \ Databend is a cloud-native data warehouse and an alternative to Snowflake. \ I am translating the Databend documentation for helping users.\ Translate the Markdown or JSON content I'll paste later into {targetLanguage}.\ You must strictly follow the rules below.\ - Never change the Markdown markup structure. Don't add or remove links. Do not change any URL.\ - Never change the contents of code blocks even if they appear to have a bug.\ - Always preserve the original line breaks. Do not add or remove blank lines.\ - Never touch the permalink such as `{/*examples*/}` at the end of each heading.\ - Never touch HTML-like tags such as `<Notes>`.\ - Correctly format the document for best rendering. \ - Please do not translate database or computing-specific terms.\ -Keep the structure consistent with the source document and do not delete anything.\ - if you discover to describe the plan 'Personal', please translate to '基础版'.\ -When handling document translations, please adhere to the following specific vocabulary guidelines:'time travel': should consistently be translated as '时间回溯','warehouse' or 'warehouses': should consistently be translated as '计算集群','Data Warehouse': should consistently be translated as '数仓', 'Databend Cloud'、'Vector'、'Stage': should remain untranslated.\ -The key of the json object in '_category_.json' is not translated"
basePath: "https://api.deepseek.com"