Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/destroy-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Destroy-deployments

on:
pull_request:
paths:
- 'doc/**/*'
types:
- closed
jobs:
destroy-deployment:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
token: "${{ secrets.GITHUB_TOKEN }}"

- name: Set branch name from source branch
run: echo "BRANCH_NAME=${GITHUB_HEAD_REF##*/}" >> $GITHUB_ENV

- name: Remove dev server deployment at ${{env.DEPLOYMENT_NAME}}
uses: strumwolf/delete-deployment-environment@v2
with:
token: "${{ secrets.TARANTOOLBOT_TOKEN }}"
environment: "translation-${{env.BRANCH_NAME}}"
51 changes: 51 additions & 0 deletions .github/workflows/pull-translation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Pull translations

on:
workflow_dispatch:
branches:
- '!master'
jobs:
pull-translations:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
token: ${{secrets.TARANTOOLBOT_TOKEN}}

- name: Set branch name from source branch
run: echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV

- name: Setup Python environment
uses: actions/setup-python@v2

- name: Setup Python requirements
run: |
python -m pip install --upgrade pip
pip install -r doc/requirements.txt

- name: Pull translations from Crowdin
uses: crowdin/github-action@1.0.21
with:
config: 'doc/crowdin.yaml'
upload_sources: false
upload_translations: false
push_translations: false
download_translations: true
download_language: 'ru'
crowdin_branch_name: ${{env.BRANCH_NAME}}
debug_mode: true
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
CROWDIN_PERSONAL_TOKEN: ${{secrets.CROWDIN_PERSONAL_TOKEN}}

- name: Cleanup translation files
run: |
sudo chown -R runner:docker doc/locale/ru/LC_MESSAGES
python doc/cleanup.py po

- name: Commit translation files
uses: stefanzweifel/git-auto-commit-action@v4.1.2
with:
commit_message: "Update translations"
file_pattern: "*.po"
57 changes: 57 additions & 0 deletions .github/workflows/push-translation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Push translation sources

on:
pull_request:
paths:
- 'doc/**/*.rst'
- 'doc/conf.py'
- '.github/workflows/push-translation.yml'
jobs:
push-translation-sources:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set branch name from source branch
run: echo "BRANCH_NAME=${GITHUB_HEAD_REF##*/}" >> $GITHUB_ENV

- name: Start translation service deployment
uses: bobheadxi/deployments@v0.5.2
id: translation
with:
step: start
token: ${{secrets.GITHUB_TOKEN}}
env: translation-${{env.BRANCH_NAME}}
ref: ${{github.head_ref}}

- name: Setup Python environment
uses: actions/setup-python@v2

- name: Setup Python requirements
run: |
python -m pip install --upgrade pip
pip install -r doc/requirements.txt

- name: Build pot files
run: python -m sphinx . doc/locale/en -c doc -b gettext

- name: Push POT files to crowdin
uses: crowdin/github-action@1.0.21
with:
upload_sources: true
upload_translations: false
crowdin_branch_name: ${{env.BRANCH_NAME}}
config: 'doc/crowdin.yaml'
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
CROWDIN_PERSONAL_TOKEN: ${{secrets.CROWDIN_PERSONAL_TOKEN}}

- name: update deployment status
uses: bobheadxi/deployments@v0.5.2
with:
step: finish
token: ${{secrets.GITHUB_TOKEN}}
status: ${{job.status}}
deployment_id: ${{steps.translation.outputs.deployment_id}}
env_url: https://crowdin.com/project/tarantool-cartridge-cli/ru#/${{env.BRANCH_NAME}}
40 changes: 40 additions & 0 deletions .github/workflows/upload-translations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Update translations on the main branch

on:
push:
paths:
- 'doc/**/*.rst'
- 'doc/locale/**/*.po'
Copy link
Contributor

@vanyarock01 vanyarock01 Jul 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do I need to run a upload when this file changes?

Copy link
Contributor

@NickVolynkin NickVolynkin Jul 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We merge translation files from a PR and then re-upload translations back to Crowdin. Unfortunately, Crowdin cannot just "merge" translations from its own branch.

- '.github/workflows/upload-translations.yml'
branches:
- master
jobs:
autocommit-pot-files:
runs-on: ubuntu-latest

steps:

- name: Checkout
uses: actions/checkout@v2

- name: Setup Python environment
uses: actions/setup-python@v2

- name: Setup Python requirements
run: |
python -m pip install --upgrade pip
pip install -r doc/requirements.txt
- name: Build pot files
run: python -m sphinx . doc/locale/en -c doc -b gettext

- name: Push Pot-files to crowdin
uses: crowdin/github-action@1.1.0
with:
config: 'doc/crowdin.yaml'
upload_sources: true
upload_translations: true
import_eq_suggestions: true
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
CROWDIN_PERSONAL_TOKEN: ${{secrets.CROWDIN_PERSONAL_TOKEN}}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,6 @@ deploy/*

ci/helm-chart/templates/crds/tarantool.io_*s_crd.yaml
ci/helm-chart/templates/crds/tarantool_*_cr.yaml

doc/locale/en/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
doc/locale/en/
doc/locale/en/
doc/output/

doc/output/
20 changes: 20 additions & 0 deletions doc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[![Crowdin](https://badges.crowdin.net/tarantool-operator/localized.svg)](https://crowdin.com/project/tarantool-operator)

# Tarantool Kubernetes Operator documentation
Part of Tarantool documentation, published to
https://www.tarantool.io/en/doc/latest/book/cartridge/cartridge_kubernetes_guide/

## Create pot files from rst
```bash
python -m sphinx doc doc/locale/en -c doc -b gettext
```

## Create/update po from pot files
```bash
sphinx-intl update -p doc/locale/en -d doc/locale -l ru
```

## Build documentation to doc/output
```bash
python -m sphinx doc doc/output -c doc
```
46 changes: 46 additions & 0 deletions doc/cleanup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#! /usr/bin/env python3
import argparse
from glob import glob
from polib import pofile, POFile, _BaseFile

parser = argparse.ArgumentParser(description='Cleanup PO and POT files')
parser.add_argument('extension', type=str, choices=['po', 'pot', 'both'],
help='cleanup files with extension: po, pot or both')


class PoFile(POFile):

def __unicode__(self):
return _BaseFile.__unicode__(self)

def metadata_as_entry(self):
class M:
def __unicode__(self, _):
return ''
return M()


def cleanup_files(extension):
mask = f'**/*.{extension}'
for file_path in glob(mask, recursive=True):
print(f'cleanup {file_path}')
po_file: POFile = pofile(file_path, klass=PoFile)
po_file.header = ''
po_file.metadata = {}
po_file.metadata_is_fuzzy = False

for item in po_file:
item.occurrences = None

po_file.save()


if __name__ == "__main__":

args = parser.parse_args()

if args.extension in ['po', 'both']:
cleanup_files('po')

if args.extension in ['pot', 'both']:
cleanup_files('pot')
23 changes: 23 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import sys
import os

sys.path.insert(0, os.path.abspath(''))

master_doc = 'doc/cartridge_kubernetes_guide/index'

source_suffix = '.rst'

project = u'Tarantool-operator'

exclude_patterns = [
'doc/locale',
'doc/output',
'doc/README.md',
'doc/cleanup.py',
'doc/requirements.txt',
]

language = 'en'
locale_dirs = ['./doc/locale']
gettext_compact = False
gettext_location = True
24 changes: 24 additions & 0 deletions doc/crowdin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# https://support.crowdin.com/configuration-file/
# https://support.crowdin.com/cli-tool-v3/#configuration

"project_id" : "463364"
"base_path" : "doc/locale"
"base_url": "https://crowdin.com"
"api_token_env": "CROWDIN_PERSONAL_TOKEN"


"preserve_hierarchy": true

files: [
{
"source" : "/en/**/*.pot",
"translation" : "/%locale_with_underscore%/LC_MESSAGES/**/%file_name%.po",
"update_option" : "update_as_unapproved",

"languages_mapping" : {
"locale_with_underscore" : {
"ru" : "ru",
}
},
}
]
Loading