2021-07-31 13:25:59 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# -*- coding: utf-8; mode: sh indent-tabs-mode: nil -*-
|
2014-02-02 22:23:57 +01:00
|
|
|
|
|
|
|
# script to easily update translation language files
|
|
|
|
|
|
|
|
# add new language:
|
2021-07-31 13:25:59 +02:00
|
|
|
# pybabel init -i searx/translations/messages.pot -d searx/translations -l en
|
2014-02-02 22:23:57 +01:00
|
|
|
|
2021-07-31 13:25:59 +02:00
|
|
|
APP_DIR="searx"
|
|
|
|
TRANSLATIONS="${APP_DIR}/translations"
|
|
|
|
MESSAGES_POT="${TRANSLATIONS}/messages.pot"
|
2014-02-02 22:23:57 +01:00
|
|
|
|
2021-07-31 13:25:59 +02:00
|
|
|
get_sha256() {
|
|
|
|
echo "$(grep "msgid" "${MESSAGES_POT}" | sort | sha256sum | cut -f1 -d\ )"
|
|
|
|
}
|
2014-02-02 22:23:57 +01:00
|
|
|
|
2021-07-31 13:25:59 +02:00
|
|
|
EXISTING_SHA="$(get_sha256)"
|
|
|
|
|
|
|
|
pybabel extract -F babel.cfg -o "${MESSAGES_POT}" "${APP_DIR}"
|
|
|
|
|
|
|
|
if [ "$(get_sha256)" = "${EXISTING_SHA}" ]; then
|
|
|
|
echo '[!] no changes detected, exiting']
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
pybabel update -N -i "${MESSAGES_POT}" -d "${TRANSLATIONS}"
|
2014-02-02 22:23:57 +01:00
|
|
|
echo '[!] update done, edit .po files if required and run pybabel compile -d searx/translations/'
|
2021-07-31 13:25:59 +02:00
|
|
|
exit 0
|