diff options
author | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2005-07-08 14:45:55 +0000 |
---|---|---|
committer | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2005-07-08 14:45:55 +0000 |
commit | fdfe5b42f687fbf3d4537541cc1b0bd9b8c2c090 (patch) | |
tree | 81d199b6fbbb11d3f310668e5bdabf9129e5f41f /src/lng.c | |
parent | 232dbc756390d30a86ae6de0cc84600eddb1c0b2 (diff) | |
download | librcc-fdfe5b42f687fbf3d4537541cc1b0bd9b8c2c090.tar.gz librcc-fdfe5b42f687fbf3d4537541cc1b0bd9b8c2c090.tar.bz2 librcc-fdfe5b42f687fbf3d4537541cc1b0bd9b8c2c090.tar.xz librcc-fdfe5b42f687fbf3d4537541cc1b0bd9b8c2c090.zip |
08.07.2005
Diffstat (limited to 'src/lng.c')
-rw-r--r-- | src/lng.c | 29 |
1 files changed, 17 insertions, 12 deletions
@@ -29,9 +29,9 @@ rcc_language_id rccGetLanguageByName(rcc_context ctx, const char *name) { else return (rcc_language_id)-1; } if (!name) return (rcc_language_id)-1; - - for (i=0;ctx->languages[i];i++) - if (!strcmp(ctx->languages[i]->sn, name)) return i; + + for (i=0;ctx->languages[i];i++) + if (!strcasecmp(ctx->languages[i]->sn, name)) return (rcc_language_id)i; return (rcc_language_id)-1; } @@ -41,16 +41,18 @@ static rcc_language_id rccGetDefaultLanguage(rcc_context ctx) { unsigned int i; char stmp[RCC_MAX_LANGUAGE_CHARS+1]; - err = rccLocaleGetLanguage(stmp, ctx->locale_variable, RCC_MAX_LANGUAGE_CHARS); - if (err) { - if (ctx->n_languages>1) return (rcc_language_id)1; - return (rcc_language_id)-1; + if (!rccLocaleGetLanguage(stmp, ctx->locale_variable, RCC_MAX_LANGUAGE_CHARS)) { + for (i=0;ctx->languages[i];i++) { + if (!strcmp(ctx->languages[i]->sn, stmp)) { + if (rccGetOption(ctx, RCC_CONFIGURED_LANGUAGES_ONLY)) { + if (!rccCheckConfig(ctx, (rcc_language_id)i)) break; + } + return (rcc_language_id)i; + } + } } - for (i=0;ctx->languages[i];i++) - if (!strcmp(ctx->languages[i]->sn, stmp)) return (rcc_language_id)i; - - if (i>1) return (rcc_language_id)1; + if (ctx->n_languages>1) return (rcc_language_id)1; return (rcc_language_id)-1; } @@ -116,17 +118,20 @@ int rccSetLanguage(rcc_context ctx, rcc_language_id language_id) { if (rcc_default_ctx) ctx = rcc_default_ctx; else return -1; } + if ((language_id < 0)||(language_id >= ctx->n_languages)) return -1; if ((!ctx->languages[language_id]->engines[0])||(!ctx->languages[language_id]->charsets[0])) return -2; if (ctx->current_language != language_id) { config = rccGetConfig(ctx, language_id); - if (!config) return -1; + // NULL is Okey (Off), if (!config) return -1; ctx->configure = 1; ctx->current_language = language_id; ctx->current_config = config; } + + return 0; } int rccSetLanguageByName(rcc_context ctx, const char *name) { |