Skip to content

Commit

Permalink
feat: add 'download_bundle' option (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-bodnar authored Feb 7, 2024
1 parent 97bef4f commit d4b35d3
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
39 changes: 39 additions & 0 deletions EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- [Upload sources only](#upload-sources-only)
- [Upload sources to the branch in Crowdin](#upload-sources-to-the-branch-in-crowdin)
- [Download only translations without pushing to a branch](#download-only-translations-without-pushing-to-a-branch)
- [Download Bundle](#download-bundle)
- [Advanced Pull Request configuration](#advanced-pull-request-configuration)
- [Custom `crowdin.yml` file location](#custom-crowdinyml-file-location)
- [Separate PRs for each target language](#separate-prs-for-each-target-language)
Expand Down Expand Up @@ -213,6 +214,44 @@ jobs:

You can use the [Create Pull Request](https://github.com/marketplace/actions/create-pull-request) GitHub Action to create a PR with the downloaded translations.

### Download Bundle

Target file bundles or simply Bundles is the feature that allows you to export sets of strings or files in the formats you select, regardless of the original file format

You can use the `download_bundle` option to download the bundle from Crowdin:

```yaml
name: Crowdin Action
on:
push:
branches: [ main ]
jobs:
crowdin:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Crowdin pull
uses: crowdin/github-action@v1
with:
download_translations: false
download_bundle: 1
create_pull_request: true
env:
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
```

> **Note**
> If you are using a **String-based** project, you need to use this option to download translations. The default `download_translations` option does not work for this type of projects.

The `download_bundle` option accepts the bundle numeric ID.

Visit the [official documentation](https://support.crowdin.com/bundles/) to learn more about Bundles.

### Advanced Pull Request configuration

There is a possibility to specify labels, assignees, reviewers for PR created by the Action.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ In case you don’t want to download translations from Crowdin (`download_transl
commit_message: 'New Crowdin translations by GitHub Action'
# this can be used to pass down any supported argument of the `download translations` cli command, e.g.
download_translations_args: '--all --skip-untranslated-strings'
download_bundle: 1 # The numeric id of the Bundle to download translations from

# This is the name of the git branch that Crowdin will create when opening a pull request.
# This branch does NOT need to be manually created. It will be created automatically by the action.
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ inputs:
download_language:
description: 'Use this option to download translations for a single specified language'
required: false
download_bundle:
description: 'Download bundle from Crowdin project (by ID)'
default: ''
required: false
skip_untranslated_strings:
description: 'Skip untranslated strings in exported files (does not work with .docx, .html, .md and other document files)'
default: 'false'
Expand Down
19 changes: 19 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,25 @@ if [ "$INPUT_DOWNLOAD_TRANSLATIONS" = true ]; then
fi
fi

if [ "$INPUT_DOWNLOAD_BUNDLE" ]; then
echo "DOWNLOADING BUNDLE $INPUT_DOWNLOAD_BUNDLE"

crowdin download bundle $INPUT_DOWNLOAD_BUNDLE $@

if [ "$INPUT_PUSH_TRANSLATIONS" = true ]; then
[ -z "${GITHUB_TOKEN}" ] && {
echo "CAN NOT FIND 'GITHUB_TOKEN' IN ENVIRONMENT VARIABLES"
exit 1
}

[ -n "${INPUT_GPG_PRIVATE_KEY}" ] && {
setup_commit_signing
}

push_to_branch
fi
fi

if [ -n "$INPUT_DELETE_CROWDIN_BRANCH" ]; then
echo "REMOVING BRANCH $INPUT_DELETE_CROWDIN_BRANCH"

Expand Down

0 comments on commit d4b35d3

Please sign in to comment.