summaryrefslogtreecommitdiffstats
path: root/src/lng.c
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2005-08-02 04:43:01 +0000
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2005-08-02 04:43:01 +0000
commit8b75f9bb6a09d54d634ff661655659951378aa2c (patch)
tree611f800f33ca919d37c724957fcc8c2b2bccb342 /src/lng.c
parente3f702e83a26468ee44f3f342a7a40a252f4603c (diff)
downloadlibrcc-8b75f9bb6a09d54d634ff661655659951378aa2c.tar.gz
librcc-8b75f9bb6a09d54d634ff661655659951378aa2c.tar.bz2
librcc-8b75f9bb6a09d54d634ff661655659951378aa2c.tar.xz
librcc-8b75f9bb6a09d54d634ff661655659951378aa2c.zip
Language autodetection
- rccConfigRecode function's are added - Language autodetection using aspell is added - Translation in 3 modes: "To English Language", "Skip English Translation", "Full" - Example2 to demonstrate translation possibilities
Diffstat (limited to 'src/lng.c')
-rw-r--r--src/lng.c45
1 files changed, 32 insertions, 13 deletions
diff --git a/src/lng.c b/src/lng.c
index b0ce7cd..4589de6 100644
--- a/src/lng.c
+++ b/src/lng.c
@@ -36,11 +36,39 @@ rcc_language_id rccGetLanguageByName(rcc_context ctx, const char *name) {
return (rcc_language_id)-1;
}
-static rcc_language_id rccGetDefaultLanguage(rcc_context ctx) {
- unsigned int i;
+int rccCheckLanguageUsability(rcc_context ctx, rcc_language_id language_id) {
+ rcc_language_config config;
rcc_option_value clo;
rcc_engine_ptr *engines;
- rcc_language_config config;
+ rcc_charset *charsets;
+
+ if (!ctx) {
+ if (rcc_default_ctx) ctx = rcc_default_ctx;
+ else return 0;
+ }
+ if (language_id>=ctx->n_languages) return 0;
+
+ language_id = rccGetRealLanguage(ctx, language_id);
+
+ clo = rccGetOption(ctx, RCC_OPTION_CONFIGURED_LANGUAGES_ONLY);
+ if (clo) {
+ config = rccCheckConfig(ctx, (rcc_language_id)language_id);
+ if ((!config)||(!config->configured)) {
+ charsets = ctx->languages[language_id]->charsets;
+ if ((charsets[0])&&(charsets[1])&&(charsets[2])) {
+ if (clo == 1) {
+ engines = ctx->languages[language_id]->engines;
+ if ((!engines[0])||(!engines[1])) return 0;
+ } else return 0;
+ }
+ }
+ }
+ return 1;
+}
+
+
+static rcc_language_id rccGetDefaultLanguage(rcc_context ctx) {
+ unsigned int i;
char stmp[RCC_MAX_LANGUAGE_CHARS+1];
if (ctx->default_language) return ctx->default_language;
@@ -48,16 +76,7 @@ static rcc_language_id rccGetDefaultLanguage(rcc_context ctx) {
if (!rccLocaleGetLanguage(stmp, ctx->locale_variable, RCC_MAX_LANGUAGE_CHARS)) {
for (i=0;ctx->languages[i];i++) {
if (!strcmp(ctx->languages[i]->sn, stmp)) {
- clo = rccGetOption(ctx, RCC_OPTION_CONFIGURED_LANGUAGES_ONLY);
- if (clo) {
- config = rccCheckConfig(ctx, (rcc_language_id)i);
- if ((!config)||(!config->configured)) {
- if (clo == 1) {
- engines = ctx->languages[i]->engines;
- if ((!engines[0])||(!engines[1])) break;
- } else break;
- }
- }
+ if (!rccCheckLanguageUsability(ctx, (rcc_language_id)i)) break;
ctx->default_language = (rcc_language_id)i;
return (rcc_language_id)i;
}