From 9dd95721d54a8d390c6cb6bb321bc5d7f94f2490 Mon Sep 17 00:00:00 2001 From: Bill Kendrick Date: Sun, 9 Apr 2023 23:07:29 -0700 Subject: [PATCH] Stamps: Don't play English descr. when not in 'en' locale Avoid playing English descriptive sound for a stamp stamp when not running in an English locale. Closes https://sourceforge.net/p/tuxpaint/bugs/261/ --- docs/CHANGES.txt | 9 +++++++++ src/tuxpaint.c | 35 ++++++++++++++++++++--------------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index 7be60942a..9f3108c87 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -7,11 +7,20 @@ Various contributors (see below, and AUTHORS.txt) https://tuxpaint.org/ 2023.April.9 (0.9.30) + * Improvements to Stamp tool: + --------------------------- + * Avoid playing English descriptive sound for a stamp + stamp when not running in an English locale. + Closes https://sourceforge.net/p/tuxpaint/bugs/261/ + Bill Kendrick + * Improvements to Shape tool: --------------------------- * Octagon allows aspect ratio change + Bill Kendrick * Slight improvement to shape calculations + Bill Kendrick * Localization Updates: --------------------- diff --git a/src/tuxpaint.c b/src/tuxpaint.c index c3e897bfa..2f279b33c 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -13702,24 +13702,29 @@ static Mix_Chunk *loadsound_extra(const char *const fname, const char *extra) debug("...No short local version of sound (WAV)!"); - strcpy(snd_fname, fname); /* malloc'd size should be sufficient */ - safe_snprintf(tmp_str, sizeof(tmp_str), "%s.ogg", extra); - strcpy((char *) strcasestr(snd_fname, ext), tmp_str); /* FIXME: Use strncpy() (ugh, complicated) */ - debug(snd_fname); - tmp_snd = Mix_LoadWAV(snd_fname); - - if (tmp_snd == NULL) - { - debug("...No default version of sound (OGG)!"); - - strcpy(snd_fname, fname); /* malloc'd size should be sufficient */ - safe_snprintf(tmp_str, sizeof(tmp_str), "%s.wav", extra); - strcpy((char *) strcasestr(snd_fname, ext), tmp_str); /* FIXME: Use strncpy() (ugh, complicated) */ + if (strcmp(extra, "_desc") != 0 || strcmp(short_lang_prefix, "en") == 0) { + /* (Not loading a descriptive sound, or we're in English locale, go ahead and fall back; + i.e., if loading a descriptive sound in a non-English locale, let's not load the + English version; see https://sourceforge.net/p/tuxpaint/bugs/261/) */ + strcpy(snd_fname, fname); /* malloc'd size should be sufficient */ + safe_snprintf(tmp_str, sizeof(tmp_str), "%s.ogg", extra); + strcpy((char *) strcasestr(snd_fname, ext), tmp_str); /* FIXME: Use strncpy() (ugh, complicated) */ debug(snd_fname); tmp_snd = Mix_LoadWAV(snd_fname); - + if (tmp_snd == NULL) - debug("...No default version of sound (WAV)!"); + { + debug("...No default version of sound (OGG)!"); + + strcpy(snd_fname, fname); /* malloc'd size should be sufficient */ + safe_snprintf(tmp_str, sizeof(tmp_str), "%s.wav", extra); + strcpy((char *) strcasestr(snd_fname, ext), tmp_str); /* FIXME: Use strncpy() (ugh, complicated) */ + debug(snd_fname); + tmp_snd = Mix_LoadWAV(snd_fname); + + if (tmp_snd == NULL) + debug("...No default version of sound (WAV)!"); + } } } }