Merge branch 'master' with export features made by Bill and some updated translations into sdl2.0
This commit is contained in:
commit
436a535003
171 changed files with 25442 additions and 13914 deletions
89
src/i18n.c
89
src/i18n.c
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
$Id$
|
||||
|
||||
June 14, 2002 - April 2, 2020
|
||||
June 14, 2002 - July 26, 2020
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
@ -263,7 +263,6 @@ int need_right_to_left;
|
|||
int need_right_to_left_word;
|
||||
const char *lang_prefix, *short_lang_prefix;
|
||||
|
||||
int num_wished_langs = 0;
|
||||
w_langs wished_langs[255];
|
||||
|
||||
/* Mappings from human-readable language names (found in
|
||||
|
|
@ -1003,36 +1002,66 @@ static void mysetenv(const char *name, const char *value)
|
|||
* @param loc Locale
|
||||
* @return The Y-nudge value for font rendering in the language.
|
||||
*/
|
||||
/* *INDENT-OFF* */
|
||||
static int set_current_language(const char *restrict locale_choice) MUST_CHECK;
|
||||
/* *INDENT-ON* */
|
||||
|
||||
static int set_current_language(const char *restrict loc)
|
||||
static int set_current_language(const char *restrict loc, int * ptr_num_wished_langs)
|
||||
{
|
||||
int i;
|
||||
int j = 0;
|
||||
char *oldloc;
|
||||
char *env_language;
|
||||
char *env_language_lang;
|
||||
char *env;
|
||||
int num_wished_langs = 0;
|
||||
|
||||
*ptr_num_wished_langs = 0;
|
||||
|
||||
if (strlen(loc) > 0)
|
||||
{
|
||||
/* Got command line or config file language */
|
||||
DEBUG_PRINTF("Language via config: %s\n", loc);
|
||||
mysetenv("LANGUAGE", loc);
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_PRINTF("Language NOT set via config\n");
|
||||
|
||||
/* Find what language to use from env vars */
|
||||
if (getenv("LANGUAGE") == NULL)
|
||||
env = getenv("LANGUAGE");
|
||||
if (env == NULL || env[0] == '\0')
|
||||
{
|
||||
if (getenv("LC_ALL"))
|
||||
mysetenv("LANGUAGE", getenv("LC_ALL"));
|
||||
else if (getenv("LC_MESSAGES"))
|
||||
mysetenv("LANGUAGE", getenv("LC_MESSAGES"));
|
||||
else if (getenv("LANG"))
|
||||
mysetenv("LANGUAGE", getenv("LANG"));
|
||||
env = getenv("LC_ALL");
|
||||
if (env != NULL && env[0] != '\0')
|
||||
{
|
||||
DEBUG_PRINTF("Language via LC_ALL: %s\n", getenv("LC_ALL"));
|
||||
mysetenv("LANGUAGE", getenv("LC_ALL"));
|
||||
}
|
||||
else
|
||||
{
|
||||
env = getenv("LC_MESSAGES");
|
||||
if (env != NULL && env[0] != '\0')
|
||||
{
|
||||
DEBUG_PRINTF("Language via LC_MESSAGES: %s\n", getenv("LC_MESSAGES"));
|
||||
mysetenv("LANGUAGE", getenv("LC_MESSAGES"));
|
||||
}
|
||||
else
|
||||
{
|
||||
env = getenv("LANG");
|
||||
if (env != NULL && env[0] != '\0')
|
||||
{
|
||||
DEBUG_PRINTF("Language via LANG: %s\n", getenv("LANG"));
|
||||
mysetenv("LANGUAGE", getenv("LANG"));
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_PRINTF("No language set!\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_PRINTF("Language was set to '%s'\n", getenv("LANGUAGE"));
|
||||
}
|
||||
}
|
||||
|
||||
oldloc = strdup(loc);
|
||||
|
|
@ -1040,15 +1069,13 @@ static int set_current_language(const char *restrict loc)
|
|||
/* First set the locale according to the environment, then try to overwrite with loc,
|
||||
after that, ctype_utf8() call will test the compatibility with utf8 and try to load
|
||||
a different locale if the resulting one is not compatible. */
|
||||
#ifdef DEBUG
|
||||
printf("Locale BEFORE is: %s\n", setlocale(LC_ALL, NULL)); //EP
|
||||
#endif
|
||||
DEBUG_PRINTF("Locale BEFORE is: %s\n", setlocale(LC_ALL, NULL)); //EP
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
setlocale(LC_ALL, loc);
|
||||
ctype_utf8();
|
||||
#ifdef DEBUG
|
||||
printf("Locale AFTER is: %s\n", setlocale(LC_ALL, NULL)); //EP
|
||||
#endif
|
||||
|
||||
DEBUG_PRINTF("Locale AFTER is: %s\n", setlocale(LC_ALL, NULL)); //EP
|
||||
|
||||
bindtextdomain("tuxpaint", LOCALEDIR);
|
||||
/* Old version of glibc does not have bind_textdomain_codeset() */
|
||||
|
|
@ -1160,9 +1187,9 @@ static int set_current_language(const char *restrict loc)
|
|||
|
||||
free(oldloc);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("lang_prefixes[%d] is \"%s\"\n", get_current_language(), lang_prefixes[get_current_language()]);
|
||||
#endif
|
||||
DEBUG_PRINTF("lang_prefixes[%d] is \"%s\"\n", get_current_language(), lang_prefixes[get_current_language()]);
|
||||
|
||||
*ptr_num_wished_langs = num_wished_langs;
|
||||
|
||||
return wished_langs[0].lang_y_nudge;
|
||||
}
|
||||
|
|
@ -1174,16 +1201,15 @@ static int set_current_language(const char *restrict loc)
|
|||
* if asked (either 'locale' or 'lang' are "help"), or if the
|
||||
* given input is not recognized.
|
||||
*
|
||||
* @param lang Language name (or NULL)
|
||||
* @param locale Locale (or NULL)
|
||||
* @param char * lang Language name (or NULL)
|
||||
* @param char * locale Locale (or NULL)
|
||||
* @param int * a place to return the number of languages we want to use, when scanning stamp descriptions
|
||||
* @return Y-nudge
|
||||
*/
|
||||
int setup_i18n(const char *restrict lang, const char *restrict locale)
|
||||
int setup_i18n(const char *restrict lang, const char *restrict locale, int * num_wished_langs)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("lang %p, locale %p\n", lang, locale);
|
||||
printf("lang \"%s\", locale \"%s\"\n", lang, locale);
|
||||
#endif
|
||||
DEBUG_PRINTF("lang %p, locale %p\n", lang, locale);
|
||||
DEBUG_PRINTF("lang \"%s\", locale \"%s\"\n", lang, locale);
|
||||
|
||||
if (locale)
|
||||
{
|
||||
|
|
@ -1204,7 +1230,7 @@ int setup_i18n(const char *restrict lang, const char *restrict locale)
|
|||
|
||||
if (locale == NULL)
|
||||
locale = "";
|
||||
return set_current_language(locale);
|
||||
return set_current_language(locale, num_wished_langs);
|
||||
}
|
||||
|
||||
#ifdef NO_SDLPANGO
|
||||
|
|
@ -1213,6 +1239,7 @@ int setup_i18n(const char *restrict lang, const char *restrict locale)
|
|||
*/
|
||||
int smash_i18n(void)
|
||||
{
|
||||
return set_current_language("C");
|
||||
int tmp;
|
||||
return set_current_language("C", &tmp);
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue