-
Notifications
You must be signed in to change notification settings - Fork 9
/
generate-downloads-table.sh
executable file
·141 lines (106 loc) · 5.12 KB
/
generate-downloads-table.sh
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
first_text="# Downloads
Currently, [Kaikki](https://kaikki.org/dictionary/rawdata.html) supports 10 wiktionary editions (en, zh, nl, fr, de, ja, ko, ru, pl, and es), so only dictionaries including these languages are available.
If the language you want isn't here, or you would like to see an improvement to a dictionary, please [open an issue](https://github.com/yomidevs/kaikki-to-yomitan/issues/new).
Some of the dictionaries listed here are small; rather than decide on a lower bound for usefulness they are all included here.
<sub><sup> Languages are referred to by their shortest [ISO code](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) (ISO 639-1 where available, [ISO 639-3](https://en.wikipedia.org/wiki/List_of_ISO_639-3_codes) where not)</sup></sub>
## Main Dictionaries
This table contains the main dictionaries:
1. Bilingual dictionaries - \`en-de\` for example has English headwords and their definitions/translations in German.
2. Monolingual dictionaries - \`en-en\` and such. These have good coverage, but tend to be verbose.
"
{
echo "$first_text"
} > downloads.md
declare -a languages="($(
jq -r '.[] | @json | @sh' languages.json
))"
columns=()
header="| |"
divider="|---|"
for language in "${languages[@]}"; do
language_name=$(echo "${language}" | jq -r '.language')
iso=$(echo "${language}" | jq -r '.iso')
hasEdition=$(echo "${language}" | jq -r '.hasEdition')
if [ "$hasEdition" = "true" ]; then
header="$header $language_name ($iso) |"
divider="$divider---|"
columns+=("$iso")
fi
done
echo "$header" > main-table.md
echo "$divider" >> main-table.md
for source_lang in "${languages[@]}"; do
source_iso=$(echo "${source_lang}" | jq -r '.iso')
source_language_name=$(echo "${source_lang}" | jq -r '.language')
flag=$(echo "${source_lang}" | jq -r '.flag')
row="| $flag </br> $source_language_name ($source_iso)"
for column in "${columns[@]}"; do
cell=""
expected_filename="${source_iso}-${column}"
cell="$cell [$expected_filename](https://github.com/yomidevs/kaikki-to-yomitan/releases/latest/download/kty-$expected_filename.zip) </br>"
row="$row | $cell"
done
echo "$row" >> main-table.md
done
cat main-table.md >> downloads.md
rm main-table.md
second_text="## IPA Dictionaries
These dictionaries contain the International Phonetic Alphabet (IPA) transcriptions for the headwords. There are two types of IPA dictionaries:
1. IPA dictionaries from a single wiktionary edition - e.g. \`en-de\` contains IPA transcriptions for English headwords from the German wiktionary edition.
2. Merged IPA dictionaries from all 8 supported editions - e.g. \`en merged\`. These have more terms covered but not all the entries might be formatted the same way.
"
{
echo "$second_text"
} >> downloads.md
ipa_header="$header Merged |"
ipa_divider="$divider---|"
ipa_columns=("${columns[@]}" "merged")
echo "$ipa_header" > ipa-table.md
echo "$ipa_divider" >> ipa-table.md
for source_lang in "${languages[@]}"; do
source_iso=$(echo "${source_lang}" | jq -r '.iso')
source_language_name=$(echo "${source_lang}" | jq -r '.language')
flag=$(echo "${source_lang}" | jq -r '.flag')
row="| $flag </br> $source_language_name ($source_iso)"
for column in "${ipa_columns[@]}"; do
cell=""
display_filename="${source_iso}-${column}"
expected_filename="${display_filename}-ipa"
if [ "$column" = "merged" ]; then
expected_filename="${source_iso}-ipa"
display_filename="${source_iso} merged"
fi
cell="$cell [$display_filename](https://github.com/yomidevs/kaikki-to-yomitan/releases/latest/download/kty-$expected_filename.zip) </br>"
row="$row | $cell"
done
echo "$row" >> ipa-table.md
done
cat ipa-table.md >> downloads.md
rm ipa-table.md
third_text="## Extra Dictionaries / Glossaries
These dictionaries are made from the "Translations" section in a Wiktionary entry. The entries are shorter and there is fewer of them compared to the main dictionaries, but they are available in some unique language pairs.
⚠️ This table is orientated opposite to the main dictionaries, with the source language in the columns and the target language in the rows.
"
{
echo "$third_text"
} >> downloads.md
echo "$header" > glossary-table.md
echo "$divider" >> glossary-table.md
for target_lang in "${languages[@]}"; do
target_iso=$(echo "${target_lang}" | jq -r '.iso')
target_language_name=$(echo "${target_lang}" | jq -r '.language')
flag=$(echo "${target_lang}" | jq -r '.flag')
row="| $flag </br> $target_language_name ($target_iso)"
for column in "${columns[@]}"; do
cell=""
if [ "$column" != "$target_iso" ]; then
display_filename="${column}"-"${target_iso}"
expected_filename="${display_filename}-gloss"
cell="$cell [$display_filename](https://github.com/yomidevs/kaikki-to-yomitan/releases/latest/download/kty-$expected_filename.zip) </br>"
fi
row="$row | $cell"
done
echo "$row" >> glossary-table.md
done
cat glossary-table.md >> downloads.md
rm glossary-table.md