-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathtranslate.sh
executable file
·51 lines (43 loc) · 1.42 KB
/
translate.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
#!/bin/sh
TRANSLATIONS_PATH="pub/firefox/releases/102.0/linux-x86_64/xpi/"
TRANSLATIONS_URI="https://ftp.mozilla.org/$TRANSLATIONS_PATH"
LANG_PACKS=$(curl -s "$TRANSLATIONS_URI" | grep -Po "(?<=$TRANSLATIONS_PATH).*?(?=\.xpi)")
TEMP_FILE="/tmp/pip-on-top-lang"
BOT_DATE=$(date "+%F %H:%M+0000")
GETTEXT="pip-on-top"
compile_mo_file() {
MO_PATH="locale/$LANG/LC_MESSAGES"
mkdir -p "$MO_PATH"
msgfmt -o "$MO_PATH/$GETTEXT.mo" "po/$LANG.po"
}
create_po_file () {
echo "# Autogenerated file
msgid \"\"
msgstr \"\"
\"Project-Id-Version: gnome-shell-extension-pip-on-top\n\"
\"PO-Revision-Date: $BOT_DATE\n\"
\"Last-Translator: BOT\n\"
\"Language-Team: THE BOTS\n\"
\"MIME-Version: 1.0\n\"
\"Content-Type: text/plain; charset=UTF-8\n\"
\"Content-Transfer-Encoding: 8bit\n\"
\"Language: $LANG\n\"
" > "po/$LANG.po"
echo "msgid \"Picture-in-Picture\"" >> "po/$LANG.po"
echo "msgstr \"$PIP_NAME\"" >> "po/$LANG.po"
compile_mo_file
}
mkdir -p "po"
while IFS= read -r LINE; do
LANG=$(echo "$LINE" | tr "-" "_")
echo "Downloading language: $LANG"
curl -s "$TRANSLATIONS_URI$LINE.xpi" -o "$TEMP_FILE"
echo "Downloaded"
PIP_NAME=$(unzip -p "$TEMP_FILE" "localization/$LINE/toolkit/pictureinpicture/pictureinpicture.ftl" \
| sed -n -e 's/^.*pictureinpicture-player-title = //p')
echo "Translation $LANG: $PIP_NAME"
create_po_file
echo "Done \"$LANG\" translation" && echo
done <<< "$LANG_PACKS"
rm "$TEMP_FILE"
echo "All done!"