Skip to content
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

chore: add workflow usage instruction and add command in action file #23

Merged
merged 1 commit into from
May 2, 2024
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
6 changes: 3 additions & 3 deletions .github/actions/extract_and_sync_translations/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ runs:

- name: Install dependencies
shell: bash
run: npm clean-install
run: npm i @deriv-com/[email protected]

- name: Run script
- name: Run extract script
shell: bash
run: deriv-extract-translations ${{ inputs.PROJECT_SOURCE_DIRECTORY }} --verbose
run: npx deriv-extract-translations ${{ inputs.PROJECT_SOURCE_DIRECTORY }} --verbose

- name: Crowdin pull action to download translations
uses: crowdin/github-action@v1
Expand Down
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This is a localization library that uses `i18next`, `react-i18next`, and a custo
- [~~`localize`~~](#localize-example)
- [`useTranslations` Hook](#usetranslations-hook)
- [Syncing translations to CDN](#syncing-translations)
- [Example usage of the action in the workflow file](#example-usage-of-the-action-in-the-workflow-file)
- [Contributing](#contributing)

## Overview
Expand Down Expand Up @@ -120,6 +121,7 @@ There is a github action that syncs the translations from Crowdin to the CDN.

The action takes following inputs:

- `PROJECT_SOURCE_DIRECTORY`: Source directory of your project by default it is `src`
- `CROWDIN_BRANCH_NAME`: Running on production, test or staging etc
- `CROWDIN_PROJECT_ID`: Crowdin project ID which can be found in the crowdin project settings
- `CROWDIN_PERSONAL_TOKEN`: Crowdin personal token which can be found in the crowdin account settings
Expand All @@ -130,6 +132,35 @@ The action takes following inputs:

Refer to the action file [here](https://github.com/deriv-com/translations/blob/main/.github/actions/extract_and_sync_translations/action.yml)

### Example usage of the action in the workflow file:

```yaml
name: Sync translations

on:
push:
branches:
- 'main'

jobs:
sync_translations:
runs-on: ubuntu-latest
steps:
- name: Checkout to main branch
uses: actions/checkout@v3

- name: Sync translations
uses: deriv-com/translations/.github/actions/extract_and_sync_translations@main
with:
CROWDIN_BRANCH_NAME: ${{ secrets.CROWDIN_BRANCH_NAME }}
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
R2_BUCKET_NAME: ${{ secrets.R2_BUCKET_NAME }}
```

## Contributing

Contributions are welcome. Please open a pull request with your changes.
Loading