diff --git a/.gitattributes b/.gitattributes index 279e21a17..e4542b025 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,4 @@ *.po diff=podiff -*.pot diff=podiff \ No newline at end of file +*.po text eol=lf +*.pot diff=podiff +*.pot text eol=lf diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 91fb2468c..23ce64b06 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,24 +1,22 @@ name: Tests - on: workflow_dispatch: push: branches: - - '**' + - "**" pull_request: branches: - - '**' + - "**" jobs: checks: + # Using matrix-tool strategy in case we want to add more tools in the future strategy: matrix: tool: - name: sphinx-lint package: sphinx-lint - command: 'sphinx-lint --enable default-role --ignore .git' - - name: Line length - command: 'awk ''{if (length($0) > 80 && length(gensub(/[^ ]/, "", "g")) > 1) {print FILENAME ":" FNR, "line too long:", $0; ERRORS+=1}} END {if (ERRORS>0) {exit 1}}'' $CHANGED_PO_FILES' + command: "sphinx-lint --enable default-role --ignore .git" name: ${{ matrix.tool.name }} (${{ matrix.tool.package }}) runs-on: ubuntu-latest @@ -30,7 +28,7 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} - uses: actions/setup-python@v4 with: - python-version: '3.11' + python-version: "3.11" - name: Install ${{ matrix.tool.package }} run: | if [ -n "${{ matrix.tool.apt_dependencies }}" ]; then @@ -57,14 +55,14 @@ jobs: fi sphinx: - name: 'Generate docs (sphinx)' + name: "Generate docs (sphinx)" runs-on: ubuntu-latest timeout-minutes: 30 steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: '3.11' + python-version: "3.11" - name: Prepare environment run: | pwd diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index c12e0ff23..8d02dd5c2 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -1,9 +1,8 @@ name: Build and Deploy to GitHub Pages - on: push: branches: - - '3.11' + - "3.11" jobs: sphinx-lint: @@ -15,14 +14,14 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} - uses: actions/setup-python@v4 with: - python-version: '3.11' + python-version: "3.11" - name: Install sphinx-lint run: python -m pip install --upgrade sphinx-lint - name: Run sphinx-lint - run: 'sphinx-lint --enable default-role --ignore .git' + run: "sphinx-lint --enable default-role --ignore .git" deploy: - name: 'Generate docs and deploy to GitHub Pages' + name: "Generate docs and deploy to GitHub Pages" runs-on: ubuntu-latest needs: sphinx-lint timeout-minutes: 30 @@ -30,7 +29,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: '3.11' + python-version: "3.11" - name: Prepare environment run: | git clone https://github.com/python/cpython.git venv/cpython/ @@ -45,5 +44,5 @@ jobs: publish_dir: ./venv/cpython/Doc/build/html publish_branch: gh-pages allow_empty_commit: true - user_name: 'github-actions[bot]' - user_email: 'github-actions[bot]@users.noreply.github.com' \ No newline at end of file + user_name: "github-actions[bot]" + user_email: "github-actions[bot]@users.noreply.github.com" diff --git a/.github/workflows/pre-commit-ci.yml b/.github/workflows/pre-commit-ci.yml new file mode 100644 index 000000000..f88ef237d --- /dev/null +++ b/.github/workflows/pre-commit-ci.yml @@ -0,0 +1,37 @@ +name: pre-commit-ci +on: + workflow_dispatch: + push: + branches: + - "**" + pull_request: + branches: + - "**" + +jobs: + pre-commit: + name: "Pre-commit checks" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + id: setup_python + with: + python-version: "3.11" + cache: pip + + - name: Install pre-commit + run: pip install --upgrade -r requirements.txt + + - name: Cache pre-commit tools + uses: actions/cache@v3 + with: + key: pre-commit-${{ runner.os }}-${{ steps.setup_python.outputs.python-version}}-${{ hashFiles('.pre-commit-config.yaml') }} + path: ~/.cache/pre-commit + + - name: Run pre-commit + run: pre-commit run --all-files --show-diff-on-failure + + - name: Run pre-commit-ci-lite + uses: pre-commit-ci/lite-action@v1.0.1 + if: always() diff --git a/.github/workflows/update_doc.yml b/.github/workflows/update_doc.yml index f9a0bfb63..9387c8d87 100644 --- a/.github/workflows/update_doc.yml +++ b/.github/workflows/update_doc.yml @@ -2,47 +2,47 @@ name: Update Doc on: workflow_dispatch: schedule: - - cron: '0 0 1 * *' + - cron: "0 0 1 * *" jobs: create_pr: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - - name: Clone CPython Repo - run: git clone https://github.com/python/cpython venv/cpython - - - name: Set Up Python 3.11 - uses: actions/setup-python@v4 - with: - python-version: "3.11" - - - name: Install dependencies - run: pip install -r requirements.txt && sudo apt install gettext -y - - - name: Run merge.py - run: python merge.py ${GITHUB_REF##*/} - - - name: Commit changes - run: | - git config --local user.email "python.docs.tr@gmail.com" - git config --local user.name "python-docs-turkish" - git commit -m "Get changes from CPython Doc for ${{ github.ref_name }}" - - - name: Create Pull Request - uses: peter-evans/create-pull-request@v4.2.3 - with: - token: ${{ secrets.BOT_PAT }} - commit-message: Get changes from CPython Doc for ${{ github.ref_name }} - author: python-docs-turkish - committer: python-docs-turkish - branch: translation-update-${{ github.ref_name }} - delete-branch: true - title: Translation Update ${{ github.ref_name }} - body: There are some changes, don't forget to translate them! - labels: update - reviewers: | - egeakman - ardasak + - uses: actions/checkout@v3 + + - name: Clone CPython Repo + run: git clone https://github.com/python/cpython venv/cpython + + - name: Set Up Python 3.11 + uses: actions/setup-python@v4 + with: + python-version: "3.11" + + - name: Install dependencies + run: pip install -r requirements.txt && sudo apt install gettext -y + + - name: Run merge.py + run: python merge.py ${GITHUB_REF##*/} + + - name: Commit changes + run: | + git config --local user.email "python.docs.tr@gmail.com" + git config --local user.name "python-docs-turkish" + git commit -m "Get changes from CPython Doc for ${{ github.ref_name }}" + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v4.2.3 + with: + token: ${{ secrets.BOT_PAT }} + commit-message: Get changes from CPython Doc for ${{ github.ref_name }} + author: python-docs-turkish + committer: python-docs-turkish + branch: translation-update-${{ github.ref_name }} + delete-branch: true + title: Translation Update ${{ github.ref_name }} + body: There are some changes, don't forget to translate them! + labels: update + reviewers: | + egeakman + ardasak diff --git a/.github/workflows/wrap_branch.yml b/.github/workflows/wrap_branch.yml index a7c99c7e5..6c59f9b46 100644 --- a/.github/workflows/wrap_branch.yml +++ b/.github/workflows/wrap_branch.yml @@ -1,11 +1,10 @@ name: "Wrap All" - on: workflow_dispatch: schedule: - - cron: '0 0 15 * *' + - cron: "0 0 15 * *" -jobs: +jobs: wrap: runs-on: ubuntu-latest steps: @@ -34,13 +33,13 @@ jobs: uses: peter-evans/create-pull-request@v4.2.3 with: token: ${{ secrets.BOT_PAT }} - commit-message: 'Wrap all files on: ${{ github.ref_name }}' + commit-message: "Wrap all files on: ${{ github.ref_name }}" branch: ${{ github.ref_name }}-wrapped delete-branch: true committer: python-docs-turkish author: python-docs-turkish - title: 'Wrap branch: ${{ github.ref_name }}' - body: 'Wrapped all files on branch: ${{ github.ref_name }}.' + title: "Wrap branch: ${{ github.ref_name }}" + body: "Wrapped all files on branch: ${{ github.ref_name }}." labels: wrap reviewers: | egeakman diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 74928844a..236103264 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,9 +1,44 @@ repos: -- repo: local + - repo: local hooks: - - id: lint - name: Run sphinx linting + - id: style-print + name: "" + entry: "style-print 'Please report any issues at: https://github.com/python/python-docs-tr/issues' 'rUBI{y}'" + language: python + additional_dependencies: ["style-print"] + pass_filenames: false + verbose: true + + - id: lint + name: Run sphinx-lint on .po files entry: sphinx-lint language: python - additional_dependencies: ['sphinx-lint==0.6.7'] - files: \.po$ \ No newline at end of file + additional_dependencies: ["sphinx-lint"] + files: \.po$ + + - repo: https://github.com/pycqa/isort + rev: 5.12.0 + hooks: + - id: isort + name: isort (python) + + - repo: https://github.com/psf/black + rev: 23.1.0 + hooks: + - id: black + name: Run black on Python files + args: ["--line-length=140", "--target-version=py311"] + files: \.py$ + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: end-of-file-fixer + - id: trailing-whitespace + + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v2.7.1 + hooks: + - id: prettier + name: Run prettier on .yml and .yaml files + types: [yaml] diff --git a/Makefile b/Makefile index 61162d2ab..294a8c680 100644 --- a/Makefile +++ b/Makefile @@ -169,4 +169,4 @@ clean: rm -rf $(POSPELL_TMP_DIR) locales/$(LANGUAGE)/LC_MESSAGES/ find -name '*.mo' -delete @echo "Cleaning build directory" - $(MAKE) -C venv/cpython/Doc/ clean \ No newline at end of file + $(MAKE) -C venv/cpython/Doc/ clean diff --git a/README.md b/README.md index b2ceef71d..3de94e85a 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Bu proje gönüllü çevirmenler ve python-docs-tr ekibi iş birliğinde sürdü #### Rezervasyon Çeviri yapmak istediğiniz bir dosyaya rezervasyon oluşturmak için şu adımları izleyin: - + 1. `Issues > New Issue > Get started` düğmelerini takip ederek rezervasyon formunu açın. 2. foo/bar.po taslağını, çalışmak istediğiniz dosyanın yolu ile değiştirin. - Örnegin, "library/functions.po üzerinde çalışmak istiyorum". diff --git a/merge.py b/merge.py index 3e15dacd1..7db4c0b76 100644 --- a/merge.py +++ b/merge.py @@ -6,12 +6,13 @@ This script is run automatically by the GitHub Actions workflow every first day of the month. """ +import argparse import re import shutil -import argparse import subprocess from pathlib import Path from subprocess import PIPE + from tqdm import tqdm diff --git a/scripts/format_check.py b/scripts/format_check.py index fd012978d..3f4957749 100644 --- a/scripts/format_check.py +++ b/scripts/format_check.py @@ -1,11 +1,11 @@ -import collections -import os import argparse +import collections import contextlib import glob -import polib +import os from pprint import pprint +import polib parser = argparse.ArgumentParser() parser.add_argument("subject", nargs="?", default=None, help="Subject to check (file or directory)") diff --git a/scripts/translate.py b/scripts/translate.py index 9b6f61393..77a94543f 100644 --- a/scripts/translate.py +++ b/scripts/translate.py @@ -1,10 +1,11 @@ import os import re import sys +from argparse import ArgumentParser +from typing import Dict, Tuple + import polib from deep_translator import DeeplTranslator, GoogleTranslator -from typing import Dict, Tuple -from argparse import ArgumentParser parser = ArgumentParser() parser.add_argument("filename", help="File to translate") diff --git a/wiki/gettext.md b/wiki/gettext.md new file mode 100644 index 000000000..9acafde4a --- /dev/null +++ b/wiki/gettext.md @@ -0,0 +1,31 @@ +# Gettext Araçları + +Bu belgede, ``gettext`` araçlarının nasıl kurulacağı açıklanmaktadır. + +## Windows + +Scoop, GNU araçlarını Windows'ta kullanmaya yarayan bir paket yöneticisidir. Scoop'u kullanarak ``gettext`` araçlarını yükleyebilirsiniz. Aşağıdaki komutları PowerShell'de çalıştırmanız gerekmektedir: + +```powershell +Set-ExecutionPolicy RemoteSigned -Scope CurrentUser +irm get.scoop.sh | iex +scoop install gettext +``` + +## Linux + +``apt`` paket yöneticisi kullanıyorsanız, gettext araçlarını şu komutla yükleyebilirsiniz: + +```bash +sudo apt update +sudo apt install gettext +``` + +## macOS + +``brew`` paket yöneticisi kullanıyorsanız, gettext araçlarını şu komutla yükleyebilirsiniz: + +```zsh +brew update +brew install gettext +```