-
Notifications
You must be signed in to change notification settings - Fork 23
146 lines (144 loc) · 5.25 KB
/
translation-updates-to-main-repo.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: Work on main branch to pull new & updated translations from tf branch
# Run on main branch
on:
push:
branches:
- 'translation-files'
paths:
- contribute-pages/**
- documentation-pages/**
- general-pages/**
- general-strings/**
# Enable running this workflow manually from the Actions tab
workflow_dispatch:
inputs:
languages:
description: "Languages to pull (if none provided the site's config-file will be used)"
required: false
type: string
jobs:
update-PO:
name: Generate & push translated files
runs-on: ubuntu-latest
steps:
# Check out the repository and download it to the runner, allowing to run actions against the code
- name: Get main repository
uses: actions/checkout@v4
with:
ref: master
- name: Get translation repository
uses: actions/checkout@v4
with:
ref: translation-files
path: translation-files
- run: git branch
- run: ls -al
- name: Install mdpo
run: |
pip install mdpo
po2md --version
- name: Set languages
id: lang-set
run: |
if [[ -n "${{ github.event.inputs.languages }}" ]]; then
languagelist=${{ github.event.inputs.languages }}
else
languagelist=$(cat _config.yml | grep "languages: \[.*\]" )
languagelist=${languagelist//[}
languagelist=${languagelist//]}
echo $languagelist
languagelist=${languagelist//'languages: '}
fi
languagelist=${languagelist//,}
languagelist=${languagelist//;}
# Exclude English (source) from list of languages to update
languagelist=${languagelist//'en'}
# Make variable consistent between steps
echo "languages=$languagelist" >> $GITHUB_ENV
- name: Print tree
run: |
sudo apt-get install tree
tree -L 2
- name: Print languages
run: |
languages=(${{ env.languages }})
for language in "${languages[@]}"
do echo $language
done
- name: Make Contribution pages
run: |
cd _i18n/en/contribute
languages=(${{ env.languages }})
for language in "${languages[@]}"
do mkdir -p ../../$language/contribute
done
for file in *
do
for language in "${languages[@]}"
do po2md $file --po-files ../../../translation-files/contribute-pages/site-contribute_$language.po --save ../../$language/contribute/$file --wrapwidth inf
git add ../../$language/contribute/$file
done
done
- name: Make Documentation pages
run: |
# top-level md files
cd _i18n/en/documentation
languages=(${{ env.languages }})
for language in "${languages[@]}"
do mkdir -p ../../$language/documentation
done
for file in *.md
do
for language in "${languages[@]}"
do po2md $file --po-files ../../../translation-files/documentation-pages/site-documentation_$language.po --save ../../$language/documentation/$file --wrapwidth inf
git add ../../$language/documentation/$file
done
done
# sub-level files
documentation_groups=(automation bugs-first-aid general getting-started playback podcasters-hosters queue subscriptions)
for category in "${documentation_groups[@]}"
do
cd $category
languages=(${{ env.languages }})
for language in "${languages[@]}"
do mkdir -p ../../../$language/documentation/$category
done
for file in *
do
for language in "${languages[@]}"
do
po2md $file --po-files ../../../../translation-files/documentation-pages/site-documentation_$language.po --save ../../../$language/documentation/$category/$file --wrapwidth inf
git add ../../../$language/documentation/$category/$file
done
done
cd ../
done
- name: Make General pages
run: |
cd _i18n/en/general
ls
languages=(${{ env.languages }})
for language in "${languages[@]}"
do mkdir -p ../../$language/general
done
for file in *
do
for language in "${languages[@]}"
do po2md $file --po-files ../../../translation-files/general-pages/site-general_$language.po --save ../../$language/general/$file --wrapwidth inf
git add ../../$language/general/$file
done
done
- name: Stage yml files
run: |
languages=(${{ env.languages }})
for language in "${languages[@]}"
do cp translation-files/general-strings/$language.yml _i18n/$language.yml
git add _i18n/$language.yml
done
- name: Commit changes
run: |
git config user.name "AntennaPod Translations Bot"
git config user.email "<[email protected]>"
git status
git commit -m "Update website with new translations"
git push origin master