indent i18n.c i18n.h
This commit is contained in:
parent
967d37d8a7
commit
5b4e0dd53f
2 changed files with 365 additions and 364 deletions
106
src/i18n.c
106
src/i18n.c
|
|
@ -426,13 +426,12 @@ static const language_to_locale_struct language_to_locale_array[] = {
|
|||
/* Show available languages: */
|
||||
static void show_lang_usage(int exitcode)
|
||||
{
|
||||
FILE * f = exitcode ? stderr : stdout;
|
||||
FILE *f = exitcode ? stderr : stdout;
|
||||
const char *const prg = "tuxpaint";
|
||||
fprintf(f,
|
||||
"\n"
|
||||
"Usage: %s [--lang LANGUAGE]\n" "\n" "LANGUAGE may be one of:\n"
|
||||
|
||||
fprintf(f, "\n" "Usage: %s [--lang LANGUAGE]\n" "\n" "LANGUAGE may be one of:\n"
|
||||
/* C */ " english american-english\n"
|
||||
/* ach */" acholi acoli\n"
|
||||
/* ach */ " acholi acoli\n"
|
||||
/* af */ " afrikaans\n"
|
||||
/* ak */ " akan twi-fante\n"
|
||||
/* sq */ " albanian\n"
|
||||
|
|
@ -441,7 +440,7 @@ static void show_lang_usage(int exitcode)
|
|||
/* an */ " aragones\n"
|
||||
/* hy */ " armenian hayeren\n"
|
||||
/* as */ " assamese\n"
|
||||
/* ast */" asturian\n"
|
||||
/* ast */ " asturian\n"
|
||||
/* en_AU */ " australian-english\n"
|
||||
/* az */ " azerbaijani\n"
|
||||
/* bm */ " bambara\n"
|
||||
|
|
@ -475,7 +474,7 @@ static void show_lang_usage(int exitcode)
|
|||
/* ka */ " georgian\n"
|
||||
/* de */ " german deutsch\n"
|
||||
/* el */ " greek\n"
|
||||
/* gos */" gronings zudelk-veenkelonioals\n"
|
||||
/* gos */ " gronings zudelk-veenkelonioals\n"
|
||||
/* gu */ " gujarati\n"
|
||||
/* he */ " hebrew\n"
|
||||
/* hi */ " hindi\n"
|
||||
|
|
@ -490,18 +489,18 @@ static void show_lang_usage(int exitcode)
|
|||
/* ks@devanagari */ " kashmiri-devanagari\n"
|
||||
/* ks */ " kashmiri-perso-arabic\n"
|
||||
/* km */ " khmer\n"
|
||||
/* cgg */" kiga chiga\n"
|
||||
/* cgg */ " kiga chiga\n"
|
||||
/* rw */ " kinyarwanda\n"
|
||||
/* tlh */" klingon tlhIngan\n"
|
||||
/* kok */" konkani-devaganari\n"
|
||||
/* kok@roman */" konkani-roman\n"
|
||||
/* tlh */ " klingon tlhIngan\n"
|
||||
/* kok */ " konkani-devaganari\n"
|
||||
/* kok@roman */ " konkani-roman\n"
|
||||
/* ko */ " korean\n"
|
||||
/* ku */ " kurdish\n"
|
||||
/* lv */ " latvian\n"
|
||||
/* lt */ " lithuanian lietuviu\n"
|
||||
/* lg */ " luganda\n"
|
||||
/* lb */ " luxembourgish letzebuergesch\n"
|
||||
/* mai */" maithili\n"
|
||||
/* mai */ " maithili\n"
|
||||
/* mk */ " macedonian\n"
|
||||
/* ms */ " malay\n"
|
||||
/* ml */ " malayalam\n"
|
||||
|
|
@ -512,7 +511,7 @@ static void show_lang_usage(int exitcode)
|
|||
/* mn */ " mongolian\n"
|
||||
/* nr */ " ndebele\n"
|
||||
/* ne */ " nepali\n"
|
||||
/* nso */" northern-sotho sesotho-sa-leboa\n"
|
||||
/* nso */ " northern-sotho sesotho-sa-leboa\n"
|
||||
/* nn */ " norwegian nynorsk norsk\n"
|
||||
/* oc */ " occitan\n"
|
||||
/* or */ " odia oriya\n"
|
||||
|
|
@ -524,8 +523,8 @@ static void show_lang_usage(int exitcode)
|
|||
/* ro */ " romanian\n"
|
||||
/* ru */ " russian russkiy\n"
|
||||
/* sa */ " sanskrit\n"
|
||||
/* sat */" santali-devaganari\n"
|
||||
/* sat@olchiki */" santali-ol-chiki\n"
|
||||
/* sat */ " santali-devaganari\n"
|
||||
/* sat@olchiki */ " santali-ol-chiki\n"
|
||||
/* gd */ " scottish scottish-gaelic ghaidhlig\n"
|
||||
/* sr */ " serbian\n"
|
||||
/* sr@latin */ " serbian-latin\n"
|
||||
|
|
@ -552,13 +551,13 @@ static void show_lang_usage(int exitcode)
|
|||
/* ur */ " urdu\n"
|
||||
/* ca@valencia */ " valencian valencia\n"
|
||||
/* ve */ " venda\n"
|
||||
/* vec */" venetian veneto\n"
|
||||
/* vec */ " venetian veneto\n"
|
||||
/* vi */ " vietnamese\n"
|
||||
/* wa */ " walloon walon\n"
|
||||
/* wo */ " wolof\n"
|
||||
/* cy */ " welsh cymraeg\n"
|
||||
/* xh */ " xhosa\n"
|
||||
/* zam */" zapotec miahuatlan-zapotec\n"
|
||||
/* zam */ " zapotec miahuatlan-zapotec\n"
|
||||
/* zu */ " zulu\n"
|
||||
"\n", prg);
|
||||
exit(exitcode);
|
||||
|
|
@ -699,10 +698,7 @@ static void show_locale_usage(FILE * f, const char *const prg)
|
|||
" wa_BE (Walloon)\n"
|
||||
" wo_SN (Wolof)\n"
|
||||
" cy_GB (Welsh Cymraeg)\n"
|
||||
" xh_ZA (Xhosa)\n"
|
||||
" zam (Zapoteco-Miahuatlan)\n"
|
||||
" zu_ZA (Zulu)\n"
|
||||
"\n", prg);
|
||||
" xh_ZA (Xhosa)\n" " zam (Zapoteco-Miahuatlan)\n" " zu_ZA (Zulu)\n" "\n", prg);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -732,15 +728,17 @@ static void ctype_utf8(void)
|
|||
#ifndef _WIN32
|
||||
/* FIXME: should this iterate over more locales?
|
||||
A zapotec speaker may have es_MX.UTF-8 available but not have en_US.UTF-8 for example */
|
||||
const char *names[] = {"en_US.UTF8","en_US.UTF-8","UTF8","UTF-8","C.UTF-8"};
|
||||
int i = sizeof(names)/sizeof(names[0]);
|
||||
for(;;){
|
||||
if(iswprint((wchar_t)0xf7)) // division symbol -- which is in Latin-1 :-/
|
||||
const char *names[] = { "en_US.UTF8", "en_US.UTF-8", "UTF8", "UTF-8", "C.UTF-8" };
|
||||
int i = sizeof(names) / sizeof(names[0]);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (iswprint((wchar_t) 0xf7)) // division symbol -- which is in Latin-1 :-/
|
||||
return;
|
||||
if(--i < 0)
|
||||
if (--i < 0)
|
||||
break;
|
||||
setlocale(LC_CTYPE,names[i]);
|
||||
setlocale(LC_MESSAGES,names[i]);
|
||||
setlocale(LC_CTYPE, names[i]);
|
||||
setlocale(LC_MESSAGES, names[i]);
|
||||
}
|
||||
fprintf(stderr, "Failed to find a locale with iswprint() working!\n");
|
||||
#endif
|
||||
|
|
@ -750,6 +748,7 @@ static void ctype_utf8(void)
|
|||
static const char *language_to_locale(const char *langstr)
|
||||
{
|
||||
int i = sizeof language_to_locale_array / sizeof language_to_locale_array[0];
|
||||
|
||||
while (i--)
|
||||
{
|
||||
if (!strcmp(langstr, language_to_locale_array[i].language))
|
||||
|
|
@ -774,6 +773,7 @@ static void set_langint_from_locale_string(const char *restrict loc)
|
|||
size_t len_baseloc;
|
||||
int found = 0;
|
||||
int i;
|
||||
|
||||
// printf("langint %i\n", langint);
|
||||
|
||||
if (!loc)
|
||||
|
|
@ -787,7 +787,7 @@ static void set_langint_from_locale_string(const char *restrict loc)
|
|||
as a last resource reverse the scanning
|
||||
*/
|
||||
|
||||
if(dot)
|
||||
if (dot)
|
||||
*dot = '\0';
|
||||
|
||||
if (cntrycode)
|
||||
|
|
@ -801,7 +801,7 @@ static void set_langint_from_locale_string(const char *restrict loc)
|
|||
ataux = strdup(at);
|
||||
*at = '\0';
|
||||
|
||||
if(cntrycode)
|
||||
if (cntrycode)
|
||||
{
|
||||
/* ll_CC@variant */
|
||||
//if (found == 0) printf("ll_CC@variant check\n");
|
||||
|
|
@ -810,8 +810,7 @@ static void set_langint_from_locale_string(const char *restrict loc)
|
|||
for (i = 0; i < NUM_LANGS && found == 0; i++)
|
||||
{
|
||||
// Case-insensitive (both "pt_BR" and "pt_br" work, etc.)
|
||||
if (len_baseloc == strlen(lang_prefixes[i]) &&
|
||||
!strncasecmp(straux, lang_prefixes[i], len_baseloc))
|
||||
if (len_baseloc == strlen(lang_prefixes[i]) && !strncasecmp(straux, lang_prefixes[i], len_baseloc))
|
||||
{
|
||||
langint = i;
|
||||
found = 1;
|
||||
|
|
@ -819,15 +818,14 @@ static void set_langint_from_locale_string(const char *restrict loc)
|
|||
}
|
||||
}
|
||||
|
||||
/* ll@variant*/
|
||||
/* ll@variant */
|
||||
//if (found == 0) printf("ll@variant check\n");
|
||||
snprintf(straux, 255, "%s%s", baseloc, ataux);
|
||||
len_baseloc = strlen(straux);
|
||||
for (i = 0; i < NUM_LANGS && found == 0; i++)
|
||||
{
|
||||
// Case-insensitive (both "pt_BR" and "pt_br" work, etc.)
|
||||
if (len_baseloc == strlen(lang_prefixes[i]) &&
|
||||
!strncasecmp(straux, lang_prefixes[i], len_baseloc))
|
||||
if (len_baseloc == strlen(lang_prefixes[i]) && !strncasecmp(straux, lang_prefixes[i], len_baseloc))
|
||||
{
|
||||
langint = i;
|
||||
found = 1;
|
||||
|
|
@ -835,11 +833,11 @@ static void set_langint_from_locale_string(const char *restrict loc)
|
|||
}
|
||||
}
|
||||
|
||||
if(cntrycode)
|
||||
if (cntrycode)
|
||||
{
|
||||
/* ll_CC */
|
||||
//if (found == 0) printf("ll_CC check\n");
|
||||
snprintf(straux, 255, "%s%s",baseloc, ccodeaux);
|
||||
snprintf(straux, 255, "%s%s", baseloc, ccodeaux);
|
||||
len_baseloc = strlen(straux);
|
||||
|
||||
/* Which, if any, of the locales is it? */
|
||||
|
|
@ -864,8 +862,7 @@ static void set_langint_from_locale_string(const char *restrict loc)
|
|||
for (i = 0; i < NUM_LANGS && found == 0; i++)
|
||||
{
|
||||
// Case-insensitive (both "pt_BR" and "pt_br" work, etc.)
|
||||
if (len_baseloc == strlen(lang_prefixes[i]) &&
|
||||
!strncasecmp(baseloc, lang_prefixes[i], strlen(lang_prefixes[i])))
|
||||
if (len_baseloc == strlen(lang_prefixes[i]) && !strncasecmp(baseloc, lang_prefixes[i], strlen(lang_prefixes[i])))
|
||||
{
|
||||
langint = i;
|
||||
found = 1;
|
||||
|
|
@ -907,8 +904,9 @@ static void mysetenv(const char *name, const char *value)
|
|||
#ifdef HAVE_SETENV
|
||||
setenv(name, value, 1);
|
||||
#else
|
||||
int len = strlen(name)+1+strlen(value)+1;
|
||||
int len = strlen(name) + 1 + strlen(value) + 1;
|
||||
char *str = malloc(len);
|
||||
|
||||
sprintf(str, "%s=%s", name, value);
|
||||
putenv(str);
|
||||
#endif
|
||||
|
|
@ -916,11 +914,11 @@ static void mysetenv(const char *name, const char *value)
|
|||
|
||||
|
||||
static int set_current_language(const char *restrict locale_choice) MUST_CHECK;
|
||||
static int set_current_language(const char *restrict loc)
|
||||
static int set_current_language(const char *restrict loc)
|
||||
{
|
||||
int i;
|
||||
int y_nudge = 0;
|
||||
char * oldloc;
|
||||
char *oldloc;
|
||||
char *env_language;
|
||||
|
||||
|
||||
|
|
@ -949,13 +947,13 @@ static int set_current_language(const char *restrict 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
|
||||
printf("Locale BEFORE is: %s\n", setlocale(LC_ALL, NULL)); //EP
|
||||
#endif
|
||||
setlocale(LC_ALL, "");
|
||||
setlocale(LC_ALL, loc);
|
||||
ctype_utf8();
|
||||
#ifdef DEBUG
|
||||
printf ("Locale AFTER is: %s\n", setlocale(LC_ALL,NULL));//EP
|
||||
printf("Locale AFTER is: %s\n", setlocale(LC_ALL, NULL)); //EP
|
||||
#endif
|
||||
|
||||
bindtextdomain("tuxpaint", LOCALEDIR);
|
||||
|
|
@ -974,7 +972,8 @@ printf ("Locale AFTER is: %s\n", setlocale(LC_ALL,NULL));//EP
|
|||
loc = setlocale(LC_MESSAGES, NULL);
|
||||
#endif
|
||||
|
||||
if (strcmp(oldloc, "") != 0 && strcmp(loc, oldloc) != 0) {
|
||||
if (strcmp(oldloc, "") != 0 && strcmp(loc, oldloc) != 0)
|
||||
{
|
||||
/* System doesn't recognize that locale! Hack, per Albert C., is to set LC_ALL to a valid UTF-8 locale, then set LANGUAGE to the locale we want to force -bjk 2010.10.05 */
|
||||
|
||||
/* Albert's comments from December 2009:
|
||||
|
|
@ -1003,7 +1002,9 @@ printf ("Locale AFTER is: %s\n", setlocale(LC_ALL,NULL));//EP
|
|||
|
||||
mysetenv("LANGUAGE", oldloc);
|
||||
set_langint_from_locale_string(oldloc);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (getenv("LANGUAGE") == NULL)
|
||||
mysetenv("LANGUAGE", loc);
|
||||
|
|
@ -1015,6 +1016,7 @@ printf ("Locale AFTER is: %s\n", setlocale(LC_ALL,NULL));//EP
|
|||
env_language = strdup(getenv("LANGUAGE"));
|
||||
int j = 0;
|
||||
char *env_language_lang;
|
||||
|
||||
if (*env_language)
|
||||
{
|
||||
env_language_lang = strtok(env_language, ":");
|
||||
|
|
@ -1073,9 +1075,7 @@ printf ("Locale AFTER is: %s\n", setlocale(LC_ALL,NULL));//EP
|
|||
#endif
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: Language is %s (%d) %s/%s\n",
|
||||
lang_prefix, langint,
|
||||
need_right_to_left ? "(RTL)" : "",
|
||||
need_right_to_left_word ? "(RTL words)" : "");
|
||||
lang_prefix, langint, need_right_to_left ? "(RTL)" : "", need_right_to_left_word ? "(RTL words)" : "");
|
||||
fflush(stderr);
|
||||
#endif
|
||||
|
||||
|
|
@ -1095,18 +1095,18 @@ int setup_i18n(const char *restrict lang, const char *restrict locale)
|
|||
printf("lang \"%s\", locale \"%s\"\n", lang, locale);
|
||||
#endif
|
||||
|
||||
if(locale)
|
||||
if (locale)
|
||||
{
|
||||
if(!strcmp(locale,"help"))
|
||||
if (!strcmp(locale, "help"))
|
||||
{
|
||||
show_locale_usage(stdout,"tuxpaint");
|
||||
show_locale_usage(stdout, "tuxpaint");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
locale = "";
|
||||
|
||||
if(lang)
|
||||
if (lang)
|
||||
locale = language_to_locale(lang);
|
||||
#ifdef __APPLE__
|
||||
patch_i18n(locale); //EP
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ enum
|
|||
LANG_ML, /* Malayalam */
|
||||
LANG_MK, /* Macedonian */
|
||||
LANG_MN, /* Mongolian */
|
||||
LANG_MNI_BENGALI, /* Manipuri (Bengali script)*/
|
||||
LANG_MNI_BENGALI, /* Manipuri (Bengali script) */
|
||||
LANG_MNI_METEI_MAYEK, /* Manipuri (Metei Mayek script) */
|
||||
LANG_MR, /* Marath */
|
||||
LANG_MS, /* Malay */
|
||||
|
|
@ -207,8 +207,9 @@ extern w_langs wished_langs[255];
|
|||
|
||||
int get_current_language(void);
|
||||
int setup_i18n(const char *restrict lang, const char *restrict locale) MUST_CHECK;
|
||||
|
||||
#ifdef NO_SDLPANGO
|
||||
int smash_i18n(void) MUST_CHECK;
|
||||
int smash_i18n(void) MUST_CHECK;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue