Improved support for localized Stamp sound effects (e.g., "en_GB" for

British English now works; only "en" would have worked before).
This commit is contained in:
William Kendrick 2008-09-23 00:06:42 +00:00
parent d233fdee95
commit 77388a8c1b
4 changed files with 67 additions and 20 deletions

View file

@ -8,7 +8,7 @@ http://www.tuxpaint.org/
$Id$
2008.September.1 (0.9.21)
2008.September.22 (0.9.21)
* New Starters:
-------------
* Silver Frame
@ -107,6 +107,9 @@ $Id$
* Corrected 'oval' brush shape so that colors came out right.
(Thanks to Andrei Skoogarev)
* Improved support for localized Stamp sound effects (e.g., "en_GB" for
British English now works; only "en" would have worked before).
2008.June.26 (0.9.20)
* New translations:
-----------------

View file

@ -25,7 +25,7 @@
$Id$
June 14, 2002 - June 27, 2008
June 14, 2002 - September 22, 2008
*/
#include <stdio.h>
@ -178,7 +178,7 @@ char *langstr;
int need_own_font;
int need_right_to_left;
int need_right_to_left_word;
const char *lang_prefix;
const char *lang_prefix, *short_lang_prefix;
const language_to_locale_struct language_to_locale_array[] = {
{"english", "C"},
@ -344,7 +344,7 @@ void ctype_utf8(void)
int set_current_language(void)
{
char *loc;
char *loc, *baseloc;
int i, found;
int y_nudge;
@ -396,10 +396,26 @@ int set_current_language(void)
if (loc != NULL)
{
baseloc = strdup(loc);
if (strchr(baseloc, '.') != NULL)
strcpy(strchr(baseloc, '.'), "\0");
/* Which, if any, of the locales is it? */
found = 0;
for (i = 0; i < NUM_LANGS && found == 0; i++)
{
// Case-insensitive (both "pt_BR" and "pt_br" work, etc.)
if (strlen(baseloc) == strlen(lang_prefixes[i]) &&
strncasecmp(baseloc, lang_prefixes[i], strlen(lang_prefixes[i])) == 0)
{
langint = i;
found = 1;
}
}
for (i = 0; i < NUM_LANGS && found == 0; i++)
{
// Case-insensitive (both "pt_BR" and "pt_br" work, etc.)
@ -411,10 +427,15 @@ int set_current_language(void)
}
}
/* FIXME: These don't work because we have the wrong langint...!? -bjk 2008.02.19 */
lang_prefix = lang_prefixes[langint];
short_lang_prefix = strdup(lang_prefix);
/* When in doubt, cut off country code */
if (strchr(short_lang_prefix, '_') != NULL)
strcpy(strchr(short_lang_prefix, '_'), "\0");
need_own_font = search_int_array(langint, lang_use_own_font);
need_right_to_left = search_int_array(langint, lang_use_right_to_left);
need_right_to_left_word = search_int_array(langint, lang_use_right_to_left_word);
@ -425,7 +446,7 @@ int set_current_language(void)
if (lang_y_nudge[i][0] == langint)
{
y_nudge = lang_y_nudge[i][1];
printf("y_nudge = %d\n", y_nudge);
//printf("y_nudge = %d\n", y_nudge);
}
}

View file

@ -10,7 +10,7 @@
$Id$
June 14, 2002 - April 5, 2008
June 14, 2002 - September 22, 2008
*/
@ -128,7 +128,7 @@ extern char *langstr;
extern int need_own_font;
extern int need_right_to_left; // Right-justify
extern int need_right_to_left_word; // Words need to be reversed, too! (e.g., Hebrew, but not Arabic)
extern const char *lang_prefix;
extern const char *lang_prefix, *short_lang_prefix;
extern const language_to_locale_struct language_to_locale_array[];

View file

@ -22,7 +22,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
June 14, 2002 - July 20, 2008
June 14, 2002 - September 22, 2008
$Id$
*/
@ -10743,7 +10743,6 @@ static Mix_Chunk *loadsound_extra(const char *const fname, const char *extra)
return (NULL);
}
/* First, check for localized version of sound: */
snd_fname = malloc(strlen(fname) + strlen(lang_prefix) + 16);
@ -10768,26 +10767,50 @@ static Mix_Chunk *loadsound_extra(const char *const fname, const char *extra)
{
debug("...No local version of sound (WAV)!");
/* Now, check for default sound: */
/* Check for non-country-code locale */
strcpy(snd_fname, fname);
snprintf(tmp_str, sizeof(tmp_str), "%s.ogg", extra);
snprintf(tmp_str, sizeof(tmp_str), "%s_%s.ogg", extra, short_lang_prefix);
strcpy((char *) strcasestr(snd_fname, ext), tmp_str);
debug(snd_fname);
tmp_snd = Mix_LoadWAV(snd_fname);
if (tmp_snd == NULL)
{
debug("...No default version of sound (OGG)!");
debug("...No short local version of sound (OGG)!");
strcpy(snd_fname, fname);
snprintf(tmp_str, sizeof(tmp_str), "%s.wav", extra);
strcpy((char *) strcasestr(snd_fname, ext), tmp_str);
debug(snd_fname);
tmp_snd = Mix_LoadWAV(snd_fname);
strcpy(snd_fname, fname);
snprintf(tmp_str, sizeof(tmp_str), "%s_%s.wav", extra, short_lang_prefix);
strcpy((char *) strcasestr(snd_fname, ext), tmp_str);
debug(snd_fname);
tmp_snd = Mix_LoadWAV(snd_fname);
if (tmp_snd == NULL)
debug("...No default version of sound (WAV)!");
if (tmp_snd == NULL)
{
/* Now, check for default sound: */
debug("...No short local version of sound (WAV)!");
strcpy(snd_fname, fname);
snprintf(tmp_str, sizeof(tmp_str), "%s.ogg", extra);
strcpy((char *) strcasestr(snd_fname, ext), tmp_str);
debug(snd_fname);
tmp_snd = Mix_LoadWAV(snd_fname);
if (tmp_snd == NULL)
{
debug("...No default version of sound (OGG)!");
strcpy(snd_fname, fname);
snprintf(tmp_str, sizeof(tmp_str), "%s.wav", extra);
strcpy((char *) strcasestr(snd_fname, ext), tmp_str);
debug(snd_fname);
tmp_snd = Mix_LoadWAV(snd_fname);
if (tmp_snd == NULL)
debug("...No default version of sound (WAV)!");
}
}
}
}
}