Skip to content

Commit

Permalink
Move Crowdin over to GH Actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Senexis committed Jan 12, 2022
1 parent 63307d8 commit 1e1d43a
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 67 deletions.
21 changes: 21 additions & 0 deletions .github/crowdin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
project_id_env: CROWDIN_PROJECT_ID
api_token_env: CROWDIN_PERSONAL_TOKEN
base_path: "./langs"
preserve_hierarchy: true

files:
[
{
type: "json",
source: "en.json",
translation: "%osx_locale%.json",
languages_mapping:
{
osx_locale:
{
"zh-CN": "zh_Hans",
"zh-TW": "zh_Hant"
}
},
}
]
File renamed without changes.
6 changes: 3 additions & 3 deletions crowdin/package.json → .github/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "crowdin",
"name": "readme",
"version": "1.0.0",
"description": "",
"main": "index.js",
"main": "readme.js",
"scripts": {
"start": "node index.js"
"start": "node readme.js"
},
"keywords": [],
"author": "",
Expand Down
17 changes: 10 additions & 7 deletions crowdin/index.js → .github/readme.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
const { TranslationStatus, Reports } = require('@crowdin/crowdin-api-client');
const fetch = require('node-fetch');
const fs = require('fs');
const path = require('path');
require('dotenv').config();

const basepath = path.join(__dirname, '..');

const status = new TranslationStatus({
token: process.env.API_TOKEN,
token: process.env.CROWDIN_PERSONAL_TOKEN,
});

const api = new Reports({
token: process.env.API_TOKEN,
token: process.env.CROWDIN_PERSONAL_TOKEN,
});

function sleep(ms) {
Expand All @@ -17,7 +20,7 @@ function sleep(ms) {

async function getTopMembers() {
try {
const projectId = process.env.PROJECT_ID;
const projectId = process.env.CROWDIN_PROJECT_ID;
const apiMaxTryCount = 5;

const projectProgress = {};
Expand Down Expand Up @@ -135,7 +138,7 @@ async function getTopMembers() {
delete projectProgress[key];
});

fs.writeFileSync('data/lang_progress.json', JSON.stringify(projectProgress));
fs.writeFileSync(path.join(basepath, 'data', 'lang_progress.json'), JSON.stringify(projectProgress));
} catch (error) {
console.error('langProgress', JSON.stringify(error));
}
Expand All @@ -162,14 +165,14 @@ async function updateReadme() {
let result = '';

result += '# Localisation contributors\n';
result += `Thanks to the following people for helping translate the project! If you are savvy in a language and feel like you want to help out, we'd greatly appreciate it! You can contribute by translating on our [Crowdin project](${process.env.PROJECT_URL}).\n\n`;
result += "Thanks to the following people for helping translate the project! If you are savvy in a language and feel like you want to help out, we'd greatly appreciate it! You can contribute by translating on our [Crowdin project](https://translate.rdo.gg/).\n\n";

result += '## Pre-Crowdin Contributors\n';
result += "We'd like to also mention the people that helped translate before the project switched to Crowdin, namely **Asya**, **flameango**, **githb123**, **glaseca**, **Gromino**, **iliggalodin**, **jeanropke**, **Kaffe97**, **Kiddamned**, **Klinorin**, **Korfeeeezy**, **Michal__d**, **MSSatari**, **Nopitch**, **Overnoes**, **pb29**, **qiexia**, **Raffox97**, **Rakmarok**, **rbcunhadesign**, **Senexis**, **sporb**, **Tiax**, **Vitor-Borba72**, **yamazakitouma**, and **yeradd12**.\n\n";

result += '## RDO Map Contributors\n';
result += "The following people helped translate the RDO Map specifically but are possibly not included on the list below: **1751020005**, **1Jay1**, **578218087**, **a.equis23**, **abdulkadiraktas**, **Aboodsaad27**, **akbcd**, **aksu.smal**, **Alexified**, **Anvnamnet**, **Aronsfeld**, **AshTurquoise**, **Atarufox**, **avojta**, **Balesz**, **beskorjake2332**, **BHT256**, **birseysoylicem**, **bruno.jacquin**, **Bruxes**, **chanito86**, **CoolBreeze-13s**, **curryguru**, **daveo979**, **djenerg**, **Doringl**, **dramatic_prophet**, **DrNuts**, **dudiv5674**, **dvagos7**, **eduardvlog**, **emrullahsimsar**, **Enrik014**, **escaliburos**, **esershnr**, **esj.h**, **ethandaxps4**, **FilipeLuk**, **FilipFelipe**, **FRANCESCADOLORES**, **FrankTVPL**, **GiorgioHerbie**, **grmaster5s**, **h_p_38**, **harleyhawke**, **HeadShot557**, **hellcat_tail**, **i_NaifKhaldi**, **idiot.rejected**, **ilyuas73**, **ingoonline11**, **Jabaay**, **JeanBankarbone**, **jeanropke**, **jeremymm1538**, **JoseLopez95**, **juandamanacor2013**, **julianforce**, **jurn0818**, **k4makazy**, **kaeporatheglitcha**, **kagurazakakotori**, **Korax94**, **Krykl**, **L1Chung**, **L2**, **L4**, **libidosiemens**, **lorenzoitalia**, **Ltf007**, **LucaBa**, **Matityahuu**, **Mattablatta**, **MEE5RUS**, **Megitsune**, **menbou**, **mgoebelm**, **michaelahofer**, **Michal__d**, **mixsiarz**, **mojan66**, **MrFermz**, **mrsanze6**, **msfern**, **Nacuman.exe**, **nahov91**, **nellonenollen**, **neohazukibr**, **Njordude**, **Nydrail**, **Overnoes**, **Pabeu**, **pach318**, **paeulchen.j**, **PeanutSlinger**, **petter.landsem.krogstad**, **PLTytus**, **Pocholo95**, **poeblu85**, **pozitive95**, **qiexiacn**, **raffouk40**, **Raffox97**, **ranforingus**, **re4k117**, **RichardC.P.**, **romuald.vanrock**, **sandratormo20**, **sayt_itoxiikoz**, **Scotmanhands**, **shar13f4**, **Shineberg**, **skonky**, **SkyFisherGames**, **SoSuz**, **Srandokan**, **ssh2**, **starblunter**, **SwinHulk**, **tabandi**, **tegetron**, **tercumantanumut**, **tharchangl**, **Tharek_Tolemac**, **TheBango**, **Tony_Bell**, **tuwangi**, **vega7621**, **viliri**, **Vinnie5412**, **W10075343**, **warkoun**, **werhel**, **wiiwil**, **windharp**, **y_ksq**, **YuYusS**, and **zrubio**\n\n"

result += '## Crowdin Contributors\n';
result += 'These are the people that helped translate the project using Crowdin. Please note that Crowdin might not always report accurate numbers due to contributions from before Crowdin.\n\n';

Expand All @@ -184,7 +187,7 @@ async function updateReadme() {
result += '\n';
});

fs.writeFileSync('langs/README.md', result);
fs.writeFileSync(path.join(basepath, 'langs', 'README.md'), result);

console.log('README updated.');
} catch (error) {
Expand Down
65 changes: 65 additions & 0 deletions .github/workflows/crowdin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Update translations

on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"

jobs:
crowdin:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Update translations
uses: crowdin/[email protected]
with:
upload_sources: true
upload_translations: true
download_translations: true

localization_branch_name: master
create_pull_request: false
push_translations: true
commit_message: "Automatic language update."

export_only_approved: false
config: ".github/crowdin.yml"
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
CROWDIN_PROJECT_ID: ${{secrets.CROWDIN_PROJECT_ID}}
CROWDIN_PERSONAL_TOKEN: ${{secrets.CROWDIN_PERSONAL_TOKEN}}
readme:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: "14"

- name: Update README
run: |
npm ci
node .github/readme.js
env:
CROWDIN_PROJECT_ID: ${{secrets.CROWDIN_PROJECT_ID}}
CROWDIN_PERSONAL_TOKEN: ${{secrets.CROWDIN_PERSONAL_TOKEN}}

- name: Commit files
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git add .
git commit -m "Update language README."
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
force: true
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,3 @@ _manifest.json
cycles_update/
fme/
rdo/

# Our credentials, don't bother removing this, you won't get our stuff. ;-)
.env
crowdin.yml
25 changes: 0 additions & 25 deletions crowdin/example-crowdin.yml

This file was deleted.

6 changes: 0 additions & 6 deletions crowdin/example.env

This file was deleted.

22 changes: 0 additions & 22 deletions crowdin/update-lang-files.sh

This file was deleted.

0 comments on commit 1e1d43a

Please sign in to comment.