[links-list] Re: [PATCH] Accept-Language & Italian trans. update

Fabio Bonelli fabiobonelli at libero.it
Wed May 1 10:33:19 PDT 2002


On Wed, May 01, 2002 at 12:05:08PM +0200, Petr Baudis wrote:

> Well, after the time I can see some benefits.. if you'll send me patch against
> ELinks, I'll add it there ;).

Good. Attached is the patch against Elinks 0.4pre6 from CVS and the
Italian translation update.

-- 
Fabio Bonelli <fabiobonelli at libero.it>
gpg fingerprint: 61E6 5442 3BDF EA0E 2D10  35A6 971B 77D1 DA7F 0F59
-------------- next part --------------
diff -bur elinks-orig/intl/english.lng elinks/intl/english.lng
--- elinks-orig/intl/english.lng	Tue Apr  9 10:07:02 2002
+++ elinks/intl/english.lng	Wed May  1 19:12:05 2002
@@ -392,3 +392,4 @@
 T_CLEAR, "Clear",
 T_ADD_BOOKMARK_LINK, "Add link to bookmarks",
 T_HK_ADD_BOOKMARK_LINK, "A",
+T_ACCEPT_LANGUAGE, "Accept-Language",
diff -bur elinks-orig/src/config/default.c elinks/src/config/default.c
--- elinks-orig/src/config/default.c	Tue Apr  2 19:40:32 2002
+++ elinks/src/config/default.c	Wed May  1 19:05:27 2002
@@ -1036,6 +1036,8 @@
 
 unsigned char user_agent[MAX_STR_LEN] = "";
 
+unsigned char accept_language[MAX_STR_LEN] = "";
+
 int startup_goto_dialog = 1;
 
 /* These are workarounds for some CGI script bugs */
@@ -1054,6 +1056,10 @@
 	 * <cmdread_cmdline>, <cmdread_file>, <cmdwrite_file>,
 	 * <minval>, <maxval>, <varname>
 	 * <description> */
+	{	"accept-language", "accept_language",
+		gen_cmd, str_rd, str_wr,
+		0, MAX_STR_LEN, accept_language,
+		"Send Accept-Language header." },
 
 	{	"accesskey-enter", "accesskey_enter",
 		gen_cmd, num_rd, num_wr,
diff -bur elinks-orig/src/config/default.h elinks/src/config/default.h
--- elinks-orig/src/config/default.h	Mon Apr  1 17:52:41 2002
+++ elinks/src/config/default.h	Wed May  1 19:05:27 2002
@@ -33,6 +33,7 @@
 
 extern int anonymous;
 extern unsigned char user_agent[];
+extern unsigned char accept_language[];
 
 extern unsigned char system_name[];
 
diff -bur elinks-orig/src/dialogs/options.c elinks/src/dialogs/options.c
--- elinks-orig/src/dialogs/options.c	Thu Apr 11 18:16:40 2002
+++ elinks/src/dialogs/options.c	Wed May  1 19:05:27 2002
@@ -185,6 +185,7 @@
 	TEXT(T_REFERER_TRUE),
 	TEXT(T_FAKE_REFERER),
 	TEXT(T_USER_AGENT),
+	TEXT(T_ACCEPT_LANGUAGE),
 	NULL
 };
 
@@ -214,20 +215,23 @@
 	y+=2;
 	dlg_format_text(NULL, term, http_labels[9], 0, &y, w, &rw, COLOR_DIALOG_TEXT, AL_LEFT);
 	y+=2;
+	dlg_format_text(NULL, term, http_labels[10], 0, &y, w, &rw, COLOR_DIALOG_TEXT, AL_LEFT);
+	y+=2;
 	dlg_format_buttons(NULL, term, dlg->items + dlg->n - 2, 2, 0, &y, w, &rw, AL_CENTER);
 	w = rw;
 	dlg->xw = rw + 2 * DIALOG_LB;
-	dlg->yw = y + 2 * DIALOG_TB;
+	dlg->yw = y + 2 * DIALOG_TB - 3;
 	center_dlg(dlg);
 	draw_dlg(dlg);
 	y = dlg->y + DIALOG_TB + 1;
-	dlg_format_checkboxes(term, term, dlg->items, dlg->n - 4, dlg->x + DIALOG_LB, &y, w, NULL, dlg->dlg->udata);
+	dlg_format_checkboxes(term, term, dlg->items, dlg->n - 5, dlg->x + DIALOG_LB, &y, w, NULL, dlg->dlg->udata);
 	y++;
 	dlg_format_text(term, term, http_labels[8], dlg->x + DIALOG_LB, &y, w, NULL, COLOR_DIALOG_TEXT, AL_LEFT);
 	dlg_format_field(term, term, dlg->items + 8, dlg->x + DIALOG_LB, &y, w, NULL, AL_LEFT);
-	y++;
 	dlg_format_text(term, term, http_labels[9], dlg->x + DIALOG_LB, &y, w, NULL, COLOR_DIALOG_TEXT, AL_LEFT);
 	dlg_format_field(term, term, dlg->items + 9, dlg->x + DIALOG_LB, &y, w, NULL, AL_LEFT);
+	dlg_format_text(term, term, http_labels[10], dlg->x + DIALOG_LB, &y, w, NULL, COLOR_DIALOG_TEXT, AL_LEFT);
+	dlg_format_field(term, term, dlg->items + 10, dlg->x + DIALOG_LB, &y, w, NULL, AL_LEFT);
 	y++;
 	dlg_format_buttons(term, term, dlg->items + dlg->n - 2, 2, dlg->x + DIALOG_LB, &y, w, &rw, AL_CENTER);
 }
@@ -239,9 +243,9 @@
 	struct http_bugs *bugs = (struct http_bugs *)di->cdata;
 	struct dialog *d;
 
-	d = mem_alloc(sizeof(struct dialog) + 13 * sizeof(struct dialog_item));
+	d = mem_alloc(sizeof(struct dialog) + 14 * sizeof(struct dialog_item));
 	if (!d) return 0;
-	memset(d, 0, sizeof(struct dialog) + 13 * sizeof(struct dialog_item));
+	memset(d, 0, sizeof(struct dialog) + 14 * sizeof(struct dialog_item));
 
 	d->title = TEXT(T_HTTP_BUG_WORKAROUNDS);
 	d->fn = httpopt_fn;
@@ -301,15 +305,19 @@
 	d->items[9].dlen = MAX_STR_LEN;
 	d->items[9].data = user_agent;
 
-	d->items[10].type = D_BUTTON;
-	d->items[10].gid = B_ENTER;
-	d->items[10].fn = ok_dialog;
-	d->items[10].text = TEXT(T_OK);
+	d->items[10].type = D_FIELD;
+	d->items[10].dlen = MAX_STR_LEN;
+	d->items[10].data = accept_language;
+
 	d->items[11].type = D_BUTTON;
-	d->items[11].gid = B_ESC;
-	d->items[11].fn = cancel_dialog;
-	d->items[11].text = TEXT(T_CANCEL);
-	d->items[12].type = D_END;
+	d->items[11].gid = B_ENTER;
+	d->items[11].fn = ok_dialog;
+	d->items[11].text = TEXT(T_OK);
+	d->items[12].type = D_BUTTON;
+	d->items[12].gid = B_ESC;
+	d->items[12].fn = cancel_dialog;
+	d->items[12].text = TEXT(T_CANCEL);
+	d->items[13].type = D_END;
 
 	do_dialog(dlg->win->term, d, getml(d, NULL));
 
diff -bur elinks-orig/src/protocol/http/http.c elinks/src/protocol/http/http.c
--- elinks-orig/src/protocol/http/http.c	Wed Mar 27 23:45:19 2002
+++ elinks/src/protocol/http/http.c	Wed May  1 19:05:27 2002
@@ -19,6 +19,7 @@
 #include <document/cache.h>
 #include <document/session.h>
 #include <intl/charsets.h>
+#include <intl/language.h>
 #include <lowlevel/connect.h>
 #include <lowlevel/sched.h>
 #include <lowlevel/terminal.h>
@@ -35,6 +36,55 @@
 	int chunk_remaining;
 };
 
+/* Country codes from ISO-639 */
+struct ccodes {
+	char *language;
+	char *ccode;
+} country_codes[] = {
+	/* English should be the first */
+	{"English", "en"},
+	{"Brazilian Portuguese", "pt-BR"},
+	{"Bulgarian", "bg"},
+	{"Catalan", "ca"},
+	{"Czech", "cs"},
+	{"Dutch", "nl"},
+	{"Estonian", "et"},
+	{"Finnish", "fi"},
+	{"French", "fr"},
+	{"Galician", "gl"},
+	{"German", "de"},
+	{"Greek", "el"},
+	{"Hungarian", "hu"},
+	{"Icelandic", "is"},
+	{"Indonesian", "id"},
+	{"Italian", "it"},
+	{"Lithuanian", "lt"},
+	{"Polish", "pl"},
+	{"Romanian", "ro"},
+	{"Russian", "ru"},
+	{"Slovak", "sk"},
+	{"Spanish", "es"},
+	{"Swedish", "sv"},
+	{"Turkish", "tr"},
+	{"Ukrainian", "uk"},
+	{NULL, NULL}
+};
+
+static char *get_country_code(int langid)
+{	
+	struct ccodes *p;
+	unsigned char *language;
+	
+	language = language_name(langid);
+	p = country_codes;
+	for (; p->language; p++)
+		if (strcmp(language, p->language) == 0)
+			return p->ccode;
+
+	/* No match, return "en" */
+	return country_codes[0].ccode;
+}
+
 static int get_http_code(unsigned char *head, int *code, int *version)
 {
 	/* \s* */
@@ -394,6 +444,12 @@
 
 		mem_free(ac);
 	}
+
+	add_to_str(&hdr, &l, "Accept-Language: ");
+	if (*accept_language)
+		add_to_str(&hdr, &l, accept_language);
+	else add_to_str(&hdr, &l, get_country_code(current_language));
+	add_to_str(&hdr, &l, "\r\n");
 
 	if (!(info->bl_flags & BL_NO_CHARSET)) {
 		add_to_str(&hdr, &l, accept_charset);
-------------- next part --------------
--- elinks-orig/intl/italian.lng	Sun Apr  7 00:10:17 2002
+++ elinks/intl/italian.lng	Wed May  1 16:48:23 2002
@@ -1,4 +1,4 @@
-T__CHAR_SET, "it-ascii",
+T__CHAR_SET, "ISO-8859-1",
 T__LANGUAGE, "Italian",
 T_BAD_NUMBER, "Numero sbagliato",
 T_NUMBER_EXPECTED, "atteso numero nel campo",
@@ -7,14 +7,14 @@
 T_BAD_STRING, "Stringa sbagliata",
 T_EMPTY_STRING_NOT_ALLOWED, "Stringa vuota non consentita",
 T_CONFIG_ERROR, "Errore configurazione",
-T_UNABLE_TO_WRITE_TO_CONFIG_FILE, "Non posso scrivere il file di configurazione",
+T_UNABLE_TO_WRITE_TO_CONFIG_FILE, "Impossible scrivere il file di configurazione",
 T_ABOUT, "About",
 T_LINKS__LYNX_LIKE, "ELinks " VERSION_STRING "\n\nWeb browser testuale.",
 T_OK, "OK",
 T_KEYS, "Tasti",
-T_KEYS_DESC, "ESC      mostra menu\n^C, q    esci\n^P, ^N   scroll su, giu'\n[, ]     scroll sinistra, destra\nup, down selezione link\n->       segui link\n<-       indietro\ng        apri url\nG        apri url relativo a url corrente\n/        cerca\n?        cerca indietro\nn        trova successivo\nN        trova precedente\n=        info documento\n\\        sorgente documento\nd        scarica",
+T_KEYS_DESC, "ESC      mostra menu\n^C, q    esci\n^P, ^N   scorri su, gi?\n[, ]     scorri sinistra, destra\nup, down seleziona link\n->       segui link\n<-       indietro\ng        apri URL\nG        apri URL relativo a URL corrente\n/        cerca\n?        cerca indietro\nn        trova successivo\nN        trova precedente\n=        info documento\n\\        sorgente documento\nd        scarica",
 T_COPYING, "Copying",
-T_COPYING_DESC, "ELinks " VERSION_STRING "\n\n(C) 1999 - 2002 Mikulas Patocka\n(C) 2001 - 2002 Petr Baudis\n\nQuesto programma e' free software; lo puoi ridistribuire e/o modificare nei termini della GNU General Public License come pubblicato dalla Free Software Foundation; sia la versione 2 della Licenza, o (a tua scelta) ogni altra versione successiva",
+T_COPYING_DESC, "ELinks " VERSION_STRING "\n\n(C) 1999 - 2002 Mikulas Patocka\n(C) 2001 - 2002 Petr Baudis\n\nQuesto programma ? software libero; lo puoi ridistribuire e/o modificare nei termini della GNU General Public License come pubblicato dalla Free Software Foundation; sia la versione 2 della Licenza, o (a tua scelta) ogni altra versione successiva",
 T_RESOURCES, "Risorse",
 T_HANDLES, "handles",
 T_TIMERS, "contatori",
@@ -49,7 +49,7 @@
 T_KOI8R_FRAMES, "Frame KOI8-R",
 T_USE_11M, "Usa ^[[11m",
 T_RESTRICT_FRAMES_IN_CP850_852, "Frame ristrette in cp850/852",
-T_BLOCK_CURSOR, "cursore a blocco",
+T_BLOCK_CURSOR, "Blocca il cursore",
 T_COLOR, "Colore",
 T_TERMINAL_OPTIONS, "Opzioni terminale",
 T_HTTP_PROXY__HOST_PORT, "Proxy HTTP (host:porta)",
@@ -123,7 +123,7 @@
 T_MAKING_CONNECTION, "Effettuo connessione",
 T_SSL_NEGOTIATION, "Negoziazione SSL in corso",
 T_REQUEST_SENT, "Richiesta spedita",
-T_LOGGING_IN, NULL,
+T_LOGGING_IN, "Login in corso",
 T_GETTING_HEADERS, "Ricezione headers",
 T_SERVER_IS_PROCESSING_REQUEST, "Il server sta elaborando la richiesta",
 T_TRANSFERRING, "Trasferimento",
@@ -144,7 +144,7 @@
 T_HTTP_100, "HTTP 100 (???)",
 T_FAKE_REFERER, "Referer HTTP fittizio",
 T_REFERER_NONE, "Nessun referer",
-T_REFERER_TRUE, "Usa URL precedente come referer (operativita' normale - NON SICURO)",
+T_REFERER_TRUE, "Usa URL precedente come referer (operativit? normale - NON SICURO)",
 T_REFERER_SAME_URL, "Usa l'URL richiesto come referer",
 T_REFERER_FAKE, "Referer fittizio",
 T_NO_CONTENT, "Nessun contenuto",
@@ -161,9 +161,9 @@
 T_OF, "di",
 T_AVG, "media",
 T_CUR, "corrente",
-T_AVERAGE_SPEED, "Velocita' media",
-T_SPEED, "Velocita'",
-T_CURRENT_SPEED, "Velocita' corrente",
+T_AVERAGE_SPEED, "Velocit? media",
+T_SPEED, "Velocit?",
+T_CURRENT_SPEED, "Velocit? corrente",
 T_ELAPSED_TIME, "Tempo trascorso",
 T_ESTIMATED_TIME, "tempo stimato",
 T_BACKGROUND, "Background",
@@ -175,7 +175,7 @@
 T_ERROR_DOWNLOADING, "Errore dureante il download",
 T_COULD_NOT_CREATE_FILE, "Non posso creare il file",
 T_UNKNOWN_TYPE, "Tipo sconosciuto",
-T_CONTEN_TYPE_IS, "Il tipo contenuto e'",
+T_CONTEN_TYPE_IS, "Content type ?",
 T_DO_YOU_WANT_TO_SAVE_OR_DISLPAY_THIS_FILE, "Vuoi salvare o visualizzare il file?",
 T_SAVE, "Salva",
 T_DISPLAY, "Visualizza",
@@ -185,17 +185,17 @@
 T_OPEN, "Apri",
 T_DO_YOU_WANT_TO_FOLLOW_REDIRECT_AND_POST_FORM_DATA_TO_URL, "Vuoi seguire la redirezione e spedire di dati all'URL",
 T_USER_AGENT, "Identificativo del browser",
-T_DO_YOU_WANT_TO_POST_FORM_DATA_TO_URL, "Vuoi spedire i dati all'url",
-T_DO_YOU_WANT_TO_REPOST_FORM_DATA_TO_URL, "Vuoi rispedire i dati all'url",
+T_DO_YOU_WANT_TO_POST_FORM_DATA_TO_URL, "Vuoi spedire i dati all'URL",
+T_DO_YOU_WANT_TO_REPOST_FORM_DATA_TO_URL, "Vuoi rispedire i dati all'URL",
 T_WARNING, "Attenzione",
 T_ERROR, "Errore",
 T_WELCOME, "Benvenuto",
 T_WELCOME_TO_LINKS, "Benvenuto in ELinks!",
-T_BASIC_HELP, "Premi ESC per il menu. Seleziona Help->Manuale nel menu' per il manuale utente.",
+T_BASIC_HELP, "Premi ESC per il menu. Seleziona Help->Manuale nel menu per il manuale utente.",
 T_LABEL, "Etichetta",
-T_CONTENT_TYPES, "Tipo(i) contenuto",
-T_PROGRAM__IS_REPLACED_WITH_FILE_NAME, "Programma ('%' e' sostituito con il nome del file)",
-T_BLOCK_TERMINAL_WHILE_PROGRAM_RUNNING, "Blocca il terminale mentre il programma e' attivo",
+T_CONTENT_TYPES, "Content-Type",
+T_PROGRAM__IS_REPLACED_WITH_FILE_NAME, "Programma ('%' ? sostituito con il nome del file)",
+T_BLOCK_TERMINAL_WHILE_PROGRAM_RUNNING, "Blocca il terminale mentre il programma ? attivo",
 T_RUN_ON_TERMINAL, "Esegui in un terminale",
 T_RUN_IN_XWINDOW, "Esegui in X-Window",
 T_ASK_BEFORE_OPENING, "Chiedi prima di aprire",
@@ -245,9 +245,9 @@
 T_YOU_ARE_NOWHERE, "Sei nel nulla!",
 T_URL, "URL",
 T_SIZE, "Dimensione",
-T_TITLE, NULL,
-T_LAST_VISIT_TIME, NULL,
-T_UNKNOWN, NULL,
+T_TITLE, "Titolo",
+T_LAST_VISIT_TIME, "Data ultima visita",
+T_UNKNOWN, "Sconosciuto",
 T_INCOMPLETE, "incompleto",
 T_CODEPAGE, "Codepage",
 T_ASSUMED, "assunta",
@@ -277,11 +277,11 @@
 T_EDIT_BOOKMARK, "Modifica bookmark",
 T_DELETE_BOOKMARK, "Cancella bookmark",
 T_BOOKMARK_MANAGER, "Gestore bookmark",
-T_GLOBAL_HISTORY, NULL,
-T_HISTORY_MANAGER, NULL,
-T_DELETE_HISTORY_ITEM, NULL,
-T_CLEAR_GLOBAL_HISTORY, NULL,
-T_SEARCH_HISTORY, NULL,
+T_GLOBAL_HISTORY, "Cronologia globale",
+T_HISTORY_MANAGER, "Cronologia globale",
+T_DELETE_HISTORY_ITEM, "Cancella elemento della cronologia",
+T_CLEAR_GLOBAL_HISTORY, "Pulisci cronologia globale",
+T_SEARCH_HISTORY, "Ricerca cronologia globale",
 T_NNAME, "Nome",
 T_EXIT_LINKS, "Chiudi ELinks",
 T_DO_YOU_REALLY_WANT_TO_EXIT_LINKS, "Vuoi veramente uscire da ELinks?",
@@ -291,13 +291,13 @@
 T_HTTP_BUG_WORKAROUNDS, "Correzioni per problemi HTTP",
 T_USE_HTTP_10, "Usa HTTP/1.0",
 T_ALLOW_SERVER_BLACKLIST, "Permetti blacklist per i server difettosi",
-T_BROKEN_302_REDIRECT, "Redirezione 302 errata (viola gli RFC, ma e' compatibile con Netscape)",
+T_BROKEN_302_REDIRECT, "Redirezione 302 errata (viola gli RFC, ma ? compatibile con Netscape)",
 T_NO_KEEPALIVE_AFTER_POST_REQUEST, "Nessuna connessione keepalive dopo una richiesta POST (necessario per alcuni database PHP difettosi)",
 T_PASSWORD_FOR_ANONYMOUS_LOGIN, "Password per login anonimo",
 T_MANUAL, "Manuale utente",
-T_MAILTO_PROG, "Programma mail (% e' sostituito con l'indirizzo)",
-T_TELNET_PROG, "Programma telnet (% e' sostituito con \"host\" o \"host port\")",
-T_TN3270_PROG, "Programma Tn3270 (% e' sostituito con \"host\" o \"host port\")",
+T_MAILTO_PROG, "Programma mail (% ? sostituito con l'indirizzo)",
+T_TELNET_PROG, "Programma telnet (% ? sostituito con \"host\" o \"host port\")",
+T_TN3270_PROG, "Programma Tn3270 (% ? sostituito con \"host\" o \"host port\")",
 T_MAIL_AND_TELNET_PROGRAMS, "Programmi mail e telnet",
 T_NO_PROGRAM, "Nessun programma",
 T_NO_PROGRAM_SPECIFIED_FOR, "Nessun programma definito per",
@@ -307,8 +307,8 @@
 T_BAD_MAILTO_URL, "URL mailto errato",
 T_BAD_TELNET_URL, "URL telnet errato",
 T_BAD_TN3270_URL, "URL tn3270 errato",
-T_USERID, NULL,
-T_PASSWORD, NULL,
+T_USERID, "Login",
+T_PASSWORD, "Password",
 T_ENTER_USERNAME, "Identificazione richiesta per ",
 T_AUTHEN, "Identificazione HTTP",
 T_AT, " a ",
@@ -316,7 +316,7 @@
 T_NO_SSL, "Questa versione di ELinks non contiene il supporto SSL/TSL",
 T_HK_ADD_BOOKMARK, "L", 
 T_HK_BOOKMARKS, "S",
-T_HK_GLOBAL_HISTORY, NULL,
+T_HK_GLOBAL_HISTORY, "Y",
 T_HK_GOTO_URL, "G",
 T_HK_GO_BACK, "B",
 T_HK_HISTORY, "C",
@@ -387,8 +387,9 @@
 T_ENTER_EXPRESSION, "Inserisci espressione",
 T_XDIALOG_TITLE, "Finestra di dialogo utente",
 T_XDIALOG_FIELD, "Un campo",
-T_NEED_MASTER_TERMINAL, "Questo e' possibile solo sul terminale principale",
+T_NEED_MASTER_TERMINAL, "Questo ? possibile solo sul terminale principale",
 T_SEARCH_BOOKMARK, "Ricerca bookmark",
 T_CLEAR, "Pulisci",
-T_ADD_BOOKMARK_LINK, NULL,
-T_HK_ADD_BOOKMARK_LINK, NULL,
+T_ADD_BOOKMARK_LINK, "Aggiungi il link ai bookmark",
+T_HK_ADD_BOOKMARK_LINK, "A",
+T_ACCEPT_LANGUAGE, "Accept-Language",


More information about the links-list mailing list