diff options
Diffstat (limited to 'manage')
| -rwxr-xr-x | manage | 58 |
1 files changed, 40 insertions, 18 deletions
@@ -5,9 +5,6 @@ # shellcheck source=utils/lib.sh source "$(dirname "${BASH_SOURCE[0]}")/utils/lib.sh" -# shellcheck source=utils/brand.env -source "${REPO_ROOT}/utils/brand.env" -source_dot_config # shellcheck source=utils/lib_static.sh source "$(dirname "${BASH_SOURCE[0]}")/utils/lib_static.sh" @@ -47,8 +44,10 @@ help() { cat <<EOF buildenv: rebuild ./utils/brand.env -babel.compile: - pybabel compile ./searx/translations +babel.: + extract : extract messages from source files and generate POT file + update : update existing message catalogs from POT file + compile : compile translation catalogs into binary MO files data.: all : update searx/languages.py and ./data/* languages : update searx/data/engines_languages.json & searx/languages.py @@ -123,23 +122,47 @@ buildenv() { return "${PIPESTATUS[0]}" } -buildenv.unset_env(){ - # Some defaults in the settings.yml are taken from the environment, - # e.g. SEARX_BIND_ADDRESS (:py:obj:`searx.settings_defaults.SHEMA`). In - # some tasks (e.g. test.robot) we do not want these envorionment applied. - unset GIT_URL - unset GIT_BRANCH - unset SEARX_URL - unset SEARX_PORT - unset SEARX_BIND_ADDRESS +babel.sha256sum() { + grep "msgid" "searx/translations/messages.pot" | sort | sha256sum | cut -f1 -d ' ' } -babel.compile() { - build_msg BABEL compile - pyenv.cmd pybabel compile -d "${REPO_ROOT}/searx/translations" +ci.babel.update() { + local sha_before + ( set -e + sha_before="$(babel.sha256sum)" + babel.extract + if [ "$(babel.sha256sum)" = "${sha_before}" ]; then + build_msg BABEL 'no changes detected, exiting' + return 1 + fi + babel.update + build_msg BABEL 'update done, edit .po files if required and run babel.compile' + ) + dump_return $? +} + +babel.extract() { + build_msg BABEL 'extract messages from source files and generate POT file' + pyenv.cmd pybabel extract -F babel.cfg \ + -o "searx/translations/messages.pot" \ + "searx/" dump_return $? } +babel.update() { + build_msg BABEL 'update existing message catalogs from POT file' + pyenv.cmd pybabel update -N \ + -i "searx/translations/messages.pot" \ + -d "searx/translations" + dump_return $? +} + +babel.compile() { + build_msg BABEL 'compile translation catalogs into binary MO files' + pyenv.cmd pybabel compile --statistics \ + -d "searx/translations" + dump_return $? +} data.all() { data.languages @@ -474,7 +497,6 @@ test.coverage() { test.robot() { build_msg TEST 'robot' - buildenv.unset_env gecko.driver PYTHONPATH=. pyenv.cmd python searx/testing.py robot dump_return $? |