From 1452f5d9266a0f87fe33ae8b00349de06746f3e8 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Mon, 26 Aug 2024 04:19:50 -0400 Subject: [PATCH] Added language translation for doom. --- .scripts/FreeDoom.sh | 53 +++++++++++++++++++++++++++++++++++++++---- linux-game-manager.sh | 2 ++ 2 files changed, 50 insertions(+), 5 deletions(-) diff --git a/.scripts/FreeDoom.sh b/.scripts/FreeDoom.sh index 3936297..b6cfb49 100755 --- a/.scripts/FreeDoom.sh +++ b/.scripts/FreeDoom.sh @@ -15,11 +15,13 @@ speak() { continue fi if [[ $startSpeech -eq 0 ]]; then - echo "${line}" | { + line=$(echo "${line}" | grep "${antiGrepStrings[@]}" | - sed "${sedStrings[@]}" | - spd-say -e ${spd_module} ${spd_pitch} ${spd_rate} ${spd_voice} ${spd_volume} -- > /dev/null 2>&1; - } + sed "${sedStrings[@]}") + if [[ "$doomLanguage" != "en" ]]; then + line=$(translate_text "$line") + fi + echo "${line}" | spd-say -e ${spd_module} ${spd_pitch} ${spd_rate} ${spd_voice} ${spd_volume} -- > /dev/null 2>&1; fi done } @@ -72,6 +74,7 @@ doomGames=( export antiGrepStrings=( '-E' '-v' + '-e' '^$' '-e' '^[0-9]' '-e' '^P_StartScript:' '-e' '^(Facing|INTRO|MAP[0-9]+|^Unknown)' @@ -80,7 +83,7 @@ export antiGrepStrings=( '-e' '^\[Toby Accessibility Mod\] (INTRO|READMe)([0-9]+).*' '-e' 'key card' '-e' '^New PDA Entry:' - '-e' "^(As |Computer Voice:|Holy|I |I've|Monorail|Ugh|What|Where)" + '-e' "^(As |Computer Voice:|Holy|I |I've|Monorail|Sector |Ugh|What|Where)" ) export sedStrings=('-E' @@ -99,6 +102,41 @@ export sedStrings=('-E' '-e' 's/ ?\*+ ?//g' ) +# Translation stuff +doomLanguage="${doomLanguage:-en}" +cache="${cache:-${XDG_CACHE_HOME:-$HOME/.cache}/linux-game-manager}" +translationDB="${cache}/doom_${doomLanguage}.sqlite" + +# Function to initialize SQLite database +init_translation_db() { + mkdir -p "$cache" + if [[ ! -f "$translationDB" ]]; then + sqlite3 "$translationDB" <\" # set speech-dispatcher module." @@ -484,6 +485,7 @@ if [[ -r "${configFile%/*}/settings.conf" ]]; then source "${configFile%/*}/settings.conf" fi unset noCache +export doomLanguage="${doomLanguage:-en}" export ipfsGateway="${ipfsGateway:-https://gateway.pinata.cloud}" export spd_module="${spd_module:+ -o ${spd_module}}" export spd_pitch="${spd_pitch:+ -p ${spd_pitch}}"