Пример #1
0
unsigned char *get_text_translation(unsigned char *text, struct terminal *term)
{
    unsigned char **current_tra;
    struct conv_table *conv_table;
    unsigned char *trn;
    int ch = term ? term->spec->charset : 0;
    if (is_direct_text(text)) return text;
    if ((current_tra = translation_array[current_language][ch])) {
        unsigned char *tt;
        if ((trn = current_tra[text - dummyarray])) return trn;
tr:
        if (!(tt = translations[current_language].t[text - dummyarray].name)) {
            trn = stracpy(translation_english[text - dummyarray].name);
        } else {
            conv_table = get_translation_table(current_lang_charset, ch);
            trn = convert_string(conv_table, tt, strlen(tt));
        }
        current_tra[text - dummyarray] = trn;
    } else {
        if (current_lang_charset && ch != current_lang_charset) {
            current_tra = translation_array[current_language][ch] = mem_alloc(sizeof (unsigned char **) * T__N_TEXTS);
            memset(current_tra, 0, sizeof (unsigned char **) * T__N_TEXTS);
            goto tr;
        }
        if (!(trn = translations[current_language].t[text - dummyarray].name)) {
            trn = translations[current_language].t[text - dummyarray].name = translation_english[text - dummyarray].name;	/* modifying translation structure */
        }
    }
    return trn;
}
Пример #2
0
unsigned char *get_text_translation(unsigned char *text, struct terminal *term)
{
	unsigned char **current_tra;
	struct conv_table *conv_table;
	unsigned char *trn;
	int charset;
	if (!term) charset = 0;
	else if (term->spec) charset = term->spec->charset;
	else charset = utf8_table;
	if (is_direct_text(text)) return text;
	if ((current_tra = translation_array[current_language][charset])) {
		unsigned char *tt;
		if ((trn = current_tra[text - dummyarray])) return trn;
		tr:
		if (!(tt = cast_uchar translations[current_language].t[text - dummyarray].name)) {
			trn = cast_uchar translation_english[text - dummyarray].name;
		} else {
			struct document_options l_opt;
			memset(&l_opt, 0, sizeof(l_opt));
			l_opt.plain = 0;
			l_opt.cp = charset;
			conv_table = get_translation_table(current_lang_charset, charset);
			trn = convert_string(conv_table, tt, (int)strlen(cast_const_char tt), &l_opt);
			if (!strcmp(cast_const_char trn, cast_const_char tt)) {
				mem_free(trn);
				trn = tt;
			}
		}
		current_tra[text - dummyarray] = trn;
	} else {
		if (current_lang_charset && charset != current_lang_charset) {
			current_tra = translation_array[current_language][charset] = mem_alloc(sizeof (unsigned char **) * T__N_TEXTS);
			memset(current_tra, 0, sizeof (unsigned char **) * T__N_TEXTS);
			goto tr;
		}
		if (!(trn = cast_uchar translations[current_language].t[text - dummyarray].name)) {
			trn = cast_uchar(translations[current_language].t[text - dummyarray].name = translation_english[text - dummyarray].name);	/* modifying translation structure */
		}
	}
	return trn;
}
Пример #3
0
unsigned char *get_english_translation(unsigned char *text)
{
	if (is_direct_text(text)) return text;
	return cast_uchar translation_english[text - dummyarray].name;
}