mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-26 16:29:36 +03:00
[project @ 2004-03-08 00:03:58 by bursa]
Implement Accept-Language option. svn path=/import/netsurf/; revision=591
This commit is contained in:
parent
1237e077c7
commit
7d9bf053b4
47
!NetSurf/Resources/LangNames
Normal file
47
!NetSurf/Resources/LangNames
Normal file
@ -0,0 +1,47 @@
|
||||
lang_af:Afrikaans
|
||||
lang_bm:Bamanankan
|
||||
lang_ca:Català
|
||||
lang_cs:Cestina
|
||||
lang_cy:Cymraeg
|
||||
lang_da:Dansk
|
||||
lang_de:Deutsch
|
||||
lang_en:English
|
||||
lang_es:Español
|
||||
lang_et:Eesti
|
||||
lang_eu:euskera
|
||||
lang_ff:Fulfulde
|
||||
lang_fi:suomi
|
||||
lang_fr:français
|
||||
lang_ga:Gaeilge
|
||||
lang_gl:Galego
|
||||
lang_ha:Hausa
|
||||
lang_hr:Hrvatski
|
||||
lang_hu:Magyar
|
||||
lang_id:Bahasa indonesia
|
||||
lang_is:Íslenska
|
||||
lang_it:italiano
|
||||
lang_lt:Lietuviskai
|
||||
lang_lv:Latviesu
|
||||
lang_ms:Bahasa melayu
|
||||
lang_mt:Malti
|
||||
lang_nl:Nederlands
|
||||
lang_no:Norsk
|
||||
lang_pl:Polski
|
||||
lang_pt:português
|
||||
lang_rn:Kirundi
|
||||
lang_ro:Româna
|
||||
lang_rw:Kinyarwanda
|
||||
lang_sk:Slovencina
|
||||
lang_sl:Slovenscina
|
||||
lang_so:Somali
|
||||
lang_sq:shqip
|
||||
lang_sr:Srpski
|
||||
lang_sv:svenska
|
||||
lang_sw:Kiswahili
|
||||
lang_tr:Türkçe
|
||||
lang_uz:o'zbek
|
||||
lang_vi:Tiêng Viêêt
|
||||
lang_wo:Wolof
|
||||
lang_xs:isiXhosa
|
||||
lang_yo:Yorùbá
|
||||
lang_zu:isiZulu
|
Binary file not shown.
Binary file not shown.
@ -276,6 +276,13 @@ struct fetch * fetch_start(char *url, char *referer,
|
||||
/* remove curl default headers */
|
||||
fetch->headers = curl_slist_append(fetch->headers, "Accept:");
|
||||
fetch->headers = curl_slist_append(fetch->headers, "Pragma:");
|
||||
if (option_accept_language) {
|
||||
char s[80];
|
||||
snprintf(s, sizeof s, "Accept-Language: %s, *;q=0.1",
|
||||
option_accept_language);
|
||||
s[sizeof s - 1] = 0;
|
||||
fetch->headers = curl_slist_append(fetch->headers, s);
|
||||
}
|
||||
code = curl_easy_setopt(fetch->curl_handle, CURLOPT_HTTPHEADER, fetch->headers);
|
||||
assert(code == CURLE_OK);
|
||||
|
||||
|
@ -39,6 +39,8 @@ int option_http_proxy_port = 8080;
|
||||
int option_font_size = 100;
|
||||
/** Minimum font size. */
|
||||
int option_font_min_size = 70;
|
||||
/** Accept-Language header. */
|
||||
char *option_accept_language = 0;
|
||||
|
||||
EXTRA_OPTION_DEFINE
|
||||
|
||||
@ -53,6 +55,7 @@ struct {
|
||||
{ "http_proxy_port", OPTION_INTEGER, &option_http_proxy_port },
|
||||
{ "font_size", OPTION_INTEGER, &option_font_size },
|
||||
{ "font_min_size", OPTION_INTEGER, &option_font_min_size },
|
||||
{ "accept_language", OPTION_STRING, &option_accept_language },
|
||||
EXTRA_OPTION_TABLE
|
||||
};
|
||||
|
||||
|
@ -29,6 +29,7 @@ extern char *option_http_proxy_host;
|
||||
extern int option_http_proxy_port;
|
||||
extern int option_font_size;
|
||||
extern int option_font_min_size;
|
||||
extern char *option_accept_language;
|
||||
|
||||
void options_read(const char *path);
|
||||
void options_write(const char *path);
|
||||
|
@ -56,6 +56,7 @@ static int file_exists(const char* base, const char* dir, const char* leaf, bits
|
||||
static void set_icon_state(wimp_w w, wimp_i i, int state);
|
||||
static int get_icon_state(wimp_w w, wimp_i i);
|
||||
static void set_icon_string_i(wimp_w w, wimp_i i, int num);
|
||||
static const char *language_name(const char *code);
|
||||
|
||||
|
||||
/**
|
||||
@ -406,6 +407,12 @@ void set_browser_choices(void)
|
||||
font_size = option_font_size;
|
||||
font_min_size = option_font_min_size;
|
||||
ro_gui_dialog_update_config_br();
|
||||
ro_gui_set_icon_string(dialog_config_br, ICON_CONFIG_BR_LANG,
|
||||
language_name(option_language ?
|
||||
option_language : "en"));
|
||||
ro_gui_set_icon_string(dialog_config_br, ICON_CONFIG_BR_ALANG,
|
||||
language_name(option_accept_language ?
|
||||
option_accept_language : "en"));
|
||||
}
|
||||
|
||||
|
||||
@ -741,3 +748,18 @@ void set_icon_string_i(wimp_w w, wimp_i i, int num)
|
||||
ro_gui_set_icon_string(w, i, buffer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert a 2-letter ISO language code to the language name.
|
||||
*
|
||||
* \param code 2-letter ISO language code
|
||||
* \return language name, or code if unknown
|
||||
*/
|
||||
|
||||
const char *language_name(const char *code)
|
||||
{
|
||||
char key[] = "lang_xx";
|
||||
key[5] = code[0];
|
||||
key[6] = code[1];
|
||||
return messages_get(key);
|
||||
}
|
||||
|
24
riscos/gui.c
24
riscos/gui.c
@ -132,25 +132,30 @@ void gui_init(int argc, char** argv)
|
||||
char theme_fname[256];
|
||||
os_error *error;
|
||||
|
||||
LOG(("starting hourglass"));
|
||||
xhourglass_start(1);
|
||||
|
||||
LOG(("reading choices"));
|
||||
LOG(("reading choices"));
|
||||
options_read("Choices:WWW.NetSurf.Choices");
|
||||
|
||||
LOG(("choosing language"));
|
||||
LOG(("choosing language"));
|
||||
ro_gui_choose_language();
|
||||
|
||||
LOG(("grabbing NetSurf$Dir from the environment"));
|
||||
NETSURF_DIR = getenv("NetSurf$Dir");
|
||||
sprintf(path, "<NetSurf$Dir>.Resources.%s.Messages", option_language);
|
||||
LOG(("Loading messages from '%s'", path));
|
||||
messages_load(path);
|
||||
messages_load("<NetSurf$Dir>.Resources.LangNames");
|
||||
|
||||
LOG(("done"));
|
||||
|
||||
task_handle = wimp_initialise(wimp_VERSION_RO38, "NetSurf",
|
||||
(wimp_message_list*) &task_messages, 0);
|
||||
error = xwimp_initialise(wimp_VERSION_RO38, "NetSurf",
|
||||
(wimp_message_list*) &task_messages, 0,
|
||||
&task_handle);
|
||||
if (error) {
|
||||
LOG(("xwimp_initialise failed: 0x%x: %s",
|
||||
error->errnum, error->errmess));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Issue a *Desktop to poke AcornURI into life */
|
||||
if (getenv("NetSurf$Start_URI_Handler"))
|
||||
@ -209,8 +214,11 @@ void ro_gui_choose_language(void)
|
||||
if (2 < strlen(option_language))
|
||||
option_language[2] = 0;
|
||||
sprintf(path, "<NetSurf$Dir>.Resources.%s", option_language);
|
||||
if (is_dir(path))
|
||||
if (is_dir(path)) {
|
||||
if (!option_accept_language)
|
||||
option_accept_language = strdup(option_language);
|
||||
return;
|
||||
}
|
||||
free(option_language);
|
||||
option_language = 0;
|
||||
}
|
||||
@ -237,6 +245,8 @@ void ro_gui_choose_language(void)
|
||||
else
|
||||
option_language = strdup("en");
|
||||
assert(option_language);
|
||||
if (!option_accept_language)
|
||||
option_accept_language = strdup(option_language);
|
||||
}
|
||||
|
||||
|
||||
|
@ -191,6 +191,10 @@ void ro_gui_save_datasave_ack(wimp_message *message);
|
||||
#define ICON_CONFIG_BR_MINSIZE 11
|
||||
#define ICON_CONFIG_BR_MINSIZE_DEC 12
|
||||
#define ICON_CONFIG_BR_MINSIZE_INC 13
|
||||
#define ICON_CONFIG_BR_LANG 15
|
||||
#define ICON_CONFIG_BR_LANG_PICK 16
|
||||
#define ICON_CONFIG_BR_ALANG 19
|
||||
#define ICON_CONFIG_BR_ALANG_PICK 20
|
||||
|
||||
#define ICON_CONFIG_PROX_OK 0
|
||||
#define ICON_CONFIG_PROX_CANCEL 1
|
||||
|
Loading…
Reference in New Issue
Block a user