SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.
Python bingbravedegoogleduckduckgogooglemetasearchprivacypythonqwantsearchsearch-enginesearxsearxngstartpageyahoo
[mod] manage - implement babel commands, drop update_translations.sh
Markus Heiser900baf2eaefc
diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.ymlindex f4ffd77be..78fc66e3f 100644--- a/.github/workflows/integration.yml+++ b/.github/workflows/integration.yml@@ -111,9 +111,7 @@ jobs:- name: Update transationsid: updatecontinue-on-error: true- run: |- pip install babel jinja2- searx_extra/update/update_translations.sh+ run: make V=1 ci.babel.update- name: Open pull requestif: steps.update.outcome == 'success'uses: peter-evans/create-pull-request@v3diff --git a/Makefile b/Makefileindex 6c22d5e2e..d48f5c531 100644--- a/Makefile+++ b/Makefile@@ -77,7 +77,7 @@ test.shell:# wrap ./manage scriptMANAGE += buildenv-MANAGE += babel.compile+MANAGE += ci.babel.update babel.extract babel.update babel.compileMANAGE += data.all data.languages data.useragents data.osm_keys_tagsMANAGE += docs.html docs.live docs.gh-pages docs.prebuild docs.cleanMANAGE += docker.build docker.push docker.buildxdiff --git a/manage b/manageindex df6b1c7d1..42c617f5b 100755--- a/manage+++ b/manage@@ -44,8 +44,10 @@ help() {cat <<EOFbuildenv: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 filesdata.:all : update searx/languages.py and ./data/*languages : update searx/data/engines_languages.json & searx/languages.py@@ -120,12 +122,47 @@ buildenv() {return "${PIPESTATUS[0]}"}-babel.compile() {- build_msg BABEL compile- pyenv.cmd pybabel compile -d "${REPO_ROOT}/searx/translations"+babel.sha256sum() {+ grep "msgid" "searx/translations/messages.pot" | sort | sha256sum | cut -f1 -d ' '+}++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.languagesdiff --git a/searx_extra/update/update_translations.sh b/searx_extra/update/update_translations.shdeleted file mode 100755index 9ad79149b..000000000--- a/searx_extra/update/update_translations.sh+++ /dev/null@@ -1,28 +0,0 @@-#!/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 searx/translations/messages.pot -d searx/translations -l en--APP_DIR="searx"-TRANSLATIONS="${APP_DIR}/translations"-MESSAGES_POT="${TRANSLATIONS}/messages.pot"--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