-
Notifications
You must be signed in to change notification settings - Fork 16
Add pull/push workflow for translations #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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}}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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' | ||
| - '.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}} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -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/ | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| doc/output/ | ||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| [](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 | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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", | ||
| } | ||
| }, | ||
| } | ||
| ] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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.