firefox{,-esr}-i18n: add script to update firefox locale

[skip ci]

Signed-off-by: Doan Tran Cong Danh <congdanhqx@gmail.com>
This commit is contained in:
Doan Tran Cong Danh 2019-09-07 18:09:55 +07:00 committed by Helmut Pozimski
parent 6313293ec5
commit f373259214
2 changed files with 82 additions and 0 deletions

View File

@ -0,0 +1 @@
../../firefox-i18n/files/update-lang-list

View File

@ -0,0 +1,81 @@
#!/bin/bash
# Copyright (c) 2019 Danh Doan
# All rights reserved.
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
version=$1
esr=""
[[ $version =~ esr$ ]] && esr="-esr"
tmpldir="firefox${esr}-i18n"
tmpoldfile="$(mktemp)"
tmpnewfile="$(mktemp)"
xoldlangexpr="^_languages="
xlistold() {
source "${tmpldir}/template"
for _lang in "${_languages[@]}"; do
_locale="${_lang%%\"*}"
[ $_locale ] && echo "$_locale"
done
}
xlink () {
ln -sf "$tmpldir" "$tmpldir-$1"
}
xnewlang () {
lang=$1
padded=$(printf '%-7s' $lang)
xoldexpr=$xoldlangexpr
xoldlangexpr="'$lang \+\""
grep -q "'$lang \+\"" "$tmpldir/template" && return 0
sed -i "/$xoldexpr/a\\
'$padded\"Unknown\"'
/checksum=/a\\
badbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadb" \
"$tmpldir/template"
}
xprocessnew() {
while read lang; do
printf '%-7s\n' $lang >&3
xlink $lang
xnewlang $lang
done
}
xcleanlang() {
while read lang; do
padded=$(printf '%-7s' $lang)
sed -i "/'$padded\"/d" $tmpldir/template
unlink "$tmpldir-$lang" || true
done
}
cd $(xdistdir)/srcpkgs
xlistold >| "$tmpoldfile"
curl "https://ftp.mozilla.org/pub/firefox/releases/$1/linux-i686/xpi/" \
| grep -o 'xpi/[a-z]\+\(-[A-Z]\+\)\?' \
| cut -d/ -f2 \
| xprocessnew 3>$tmpnewfile
grep -vF -f $tmpnewfile $tmpoldfile \
| xcleanlang
rm -rf $tmpoldfile $tmpnewfile