-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #188 from RodriSanchez1/CrowdinGithubActions
Add Github Actions to update and dowloand Crowdin translations
- Loading branch information
Showing
7 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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: Download Crowdin translations | ||
|
||
on: | ||
workflow_dispatch: | ||
# pull_request: | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
jobs: | ||
pre_translate: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Compile intl TypeScript files | ||
run: npx -p typescript tsc --project src/intl/intl.tsconfig.json | ||
|
||
- name: Get Supported Locales | ||
id: get_locales | ||
run: | | ||
supportedLocales=$(node src/intl/dist/scripts/getSupportedLocales.js) | ||
echo "supportedLocales=$supportedLocales" >> $GITHUB_ENV | ||
- name: Pre-translate | ||
uses: crowdin/github-action@v2 | ||
with: | ||
command: 'pre-translate' | ||
command_args: '--method mt ${{ env.supportedLocales }} --file cbuilder/src/intl/cbuilder.json --engine-id ${{ vars.CROWDIN_MT_ID }} --verbose' | ||
env: | ||
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} | ||
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} | ||
|
||
create_pr: | ||
runs-on: ubuntu-latest | ||
needs: pre_translate | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Synchronize with Crowdin | ||
uses: crowdin/github-action@v2 | ||
with: | ||
upload_sources: false | ||
upload_translations: false | ||
download_translations: true | ||
localization_branch_name: l10n_crowdin_translations | ||
|
||
create_pull_request: true | ||
pull_request_title: 'New Crowdin translations' | ||
pull_request_body: 'New Crowdin pull request with translations' | ||
pull_request_base_branch_name: 'main' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} | ||
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} |
This file contains 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,25 @@ | ||
name: Upload source file to Crowdin | ||
|
||
on: | ||
push: | ||
paths: ['src/intl/cbuilder.json'] | ||
branches: [main] | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
crowdin-upload-sources: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Crowdin push | ||
uses: crowdin/github-action@v2 | ||
with: | ||
upload_sources: true | ||
upload_translations: false | ||
download_translations: false | ||
env: | ||
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} | ||
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} |
This file contains 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 |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
|
||
# production | ||
/build | ||
/src/intl/dist | ||
|
||
# misc | ||
.DS_Store | ||
|
This file contains 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,16 @@ | ||
'project_id_env': 'CROWDIN_PROJECT_ID' | ||
'api_token_env': 'CROWDIN_PERSONAL_TOKEN' | ||
'base_path': './src/intl' | ||
'base_url': 'https://api.crowdin.com' | ||
|
||
'preserve_hierarchy': true | ||
|
||
files: | ||
[ | ||
{ | ||
'source': '/cbuilder.json', | ||
'translation': '/dictionaries/%locale%.json', | ||
'dest': '/cbuilder/src/intl/cbuilder.json', | ||
'type': 'json', | ||
}, | ||
] |
This file contains 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
This file contains 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,14 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "ESNext", | ||
"outDir": "./dist", | ||
"rootDir": ".", | ||
"moduleResolution": "Node", | ||
"esModuleInterop": true, | ||
"allowSyntheticDefaultImports": true, | ||
"skipLibCheck": true, | ||
"strict": true | ||
}, | ||
"files": ["./intl.constants.ts", "./scripts/getSupportedLocales.ts"] | ||
} |
This file contains 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,28 @@ | ||
//To compile the script run the following command in the terminal: | ||
//npx -p typescript tsc --project src/intl/intl.ts-config.json | ||
//To run the script, use the following command: | ||
//node src/intl/dist/getSupportedLocales.js | ||
|
||
import { | ||
supportedLocales, | ||
mapSupportedLocalesToCrowdinLanguageCodes, | ||
defaultLocale, | ||
} from '../intl.constants'; | ||
|
||
const result = supportedLocales | ||
.map((locale) => { | ||
if (!(locale in mapSupportedLocalesToCrowdinLanguageCodes)) { | ||
throw new Error( | ||
`The locale "${locale}" is not supported by Crowdin. Please add it to the "mapSupportedLocalesToCrowdinLanguageCodes" object in "src/intl/intl.constants.ts".`, | ||
); | ||
} | ||
if (locale === defaultLocale) { | ||
return ''; | ||
} | ||
|
||
const crowdinLanguageCode = | ||
mapSupportedLocalesToCrowdinLanguageCodes[locale]; | ||
return `-l ${crowdinLanguageCode}`; | ||
}) | ||
.join(' '); | ||
console.log(result); |