diff options
author | Alexandre Flament <alex@al-f.net> | 2021-07-31 13:25:59 +0200 |
---|---|---|
committer | Alexandre Flament <alex@al-f.net> | 2021-08-02 09:44:13 +0200 |
commit | d1fb3c2592632add4529b9474e644cad4e086887 (patch) | |
tree | 0456b92920a3e0ac5b08003b595580374546a64a | |
parent | efc81ca3dc7705d37e70ae1abb8847218cb853d3 (diff) | |
download | searxng-d1fb3c2592632add4529b9474e644cad4e086887.tar.gz searxng-d1fb3c2592632add4529b9474e644cad4e086887.zip |
babel: update searx_extra/update/update_translations.sh
the script expects searx/translations/messages.pot to be commited
it calls "pybabel extract", and if there is a meaningful change,
it calls "pybabel update"
exit code 0 when there is a change in messages.pot
-rwxr-xr-x | searx_extra/update/update_translations.sh | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/searx_extra/update/update_translations.sh b/searx_extra/update/update_translations.sh index 240387ae7..9ad79149b 100755 --- a/searx_extra/update/update_translations.sh +++ b/searx_extra/update/update_translations.sh @@ -1,15 +1,28 @@ -#!/bin/sh +#!/usr/bin/env bash +# -*- coding: utf-8; mode: sh indent-tabs-mode: nil -*- # script to easily update translation language files # add new language: -# pybabel init -i messages.pot -d searx/translations -l en +# pybabel init -i searx/translations/messages.pot -d searx/translations -l en -SEARX_DIR='searx' +APP_DIR="searx" +TRANSLATIONS="${APP_DIR}/translations" +MESSAGES_POT="${TRANSLATIONS}/messages.pot" -pybabel extract -F babel.cfg -o messages.pot "$SEARX_DIR" -for f in `ls "$SEARX_DIR"'/translations/'`; do - pybabel update -N -i messages.pot -d "$SEARX_DIR"'/translations/' -l "$f" -done +get_sha256() { + echo "$(grep "msgid" "${MESSAGES_POT}" | sort | sha256sum | cut -f1 -d\ )" +} +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}" echo '[!] update done, edit .po files if required and run pybabel compile -d searx/translations/' +exit 0 |