#!/bin/fish function display_help set_color green echo -n "1) " set_color normal echo "Extract translations into messages.pot file" echo " and merge into existing languages" set_color green echo -n "2) " set_color normal echo "Create translation folders for new language" set_color green echo -n "3) " set_color normal echo "Compile *.po files for display" set_color red echo -n "4) " set_color normal echo "Exit program" echo end function compile_pot set_color brgreen echo "Compiling POT file..." set_color normal set -l version "$(cat VERSION.md)" command pybabel extract -F babel.cfg -k lazy_gettext -o messages.pot --add-location full \ --project Starfall --version "$version" \ --copyright-holder "Flare Starfall" --msgid-bugs-address "flare@theflare.at" . if test -d translations set_color brgreen echo "Merging into existing languages..." set_color normal command pybabel update -i messages.pot -d translations end set_color brgreen echo -n "Command complete " set_color normal echo "- returning to menu" echo end function new_lang read -p "set_color green; echo -n \"Please enter language >>> \"; set_color normal" -l lang if test -d "translations/$lang" set_color brred echo -n "ERROR " set_color normal echo "- Language already exists" echo else set_color brgreen echo "Initializing language $lang..." set_color normal command pybabel init -i messages.pot -d translations -l "$lang" set_color brgreen echo -n "Command complete " set_color normal echo "- returning to menu" echo end end function compile_po set_color brgreen echo "Compiling PO files..." set_color normal command pybabel compile -d translations set_color brgreen echo -n "Command complete " set_color normal echo "- returning to menu" echo end source .venv/bin/activate.fish while true display_help read -p "set_color green; echo -n \"Please enter operation >>> \"; set_color normal" -n 1 -l confirm or return 1 switch $confirm case 1 compile_pot case 2 new_lang case 3 compile_po case 4 return 0 case '' '*' echo "Invalid input" continue end end