diff options
| author | 2025-02-15 06:35:47 +0100 | |
|---|---|---|
| committer | 2025-02-15 06:35:47 +0100 | |
| commit | 1554a207e653d626c194b7d8113a55358c0dcdf7 (patch) | |
| tree | 84fabbb1e475507add1b72bdbe555da56f84e68d /html.c | |
| parent | srv_open() now loads all .po files into srv_langs. (diff) | |
| download | penes-snac2-1554a207e653d626c194b7d8113a55358c0dcdf7.tar.gz penes-snac2-1554a207e653d626c194b7d8113a55358c0dcdf7.tar.xz penes-snac2-1554a207e653d626c194b7d8113a55358c0dcdf7.zip | |
The interface language preference can now be set.
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 29 |
1 files changed, 29 insertions, 0 deletions
| @@ -1243,6 +1243,28 @@ xs_html *html_top_controls(snac *user) | |||
| 1243 | else | 1243 | else |
| 1244 | metadata = xs_str_new(NULL); | 1244 | metadata = xs_str_new(NULL); |
| 1245 | 1245 | ||
| 1246 | /* ui language */ | ||
| 1247 | xs_html *lang_select = xs_html_tag("select", | ||
| 1248 | xs_html_attr("name", "web_ui_lang")); | ||
| 1249 | |||
| 1250 | const char *u_lang = xs_dict_get_def(user->config, "lang", "en"); | ||
| 1251 | const char *lang; | ||
| 1252 | const xs_dict *langs; | ||
| 1253 | |||
| 1254 | xs_dict_foreach(srv_langs, lang, langs) { | ||
| 1255 | if (strcmp(u_lang, lang) == 0) | ||
| 1256 | xs_html_add(lang_select, | ||
| 1257 | xs_html_tag("option", | ||
| 1258 | xs_html_text(lang), | ||
| 1259 | xs_html_attr("value", lang), | ||
| 1260 | xs_html_attr("selected", "selected"))); | ||
| 1261 | else | ||
| 1262 | xs_html_add(lang_select, | ||
| 1263 | xs_html_tag("option", | ||
| 1264 | xs_html_text(lang), | ||
| 1265 | xs_html_attr("value", lang))); | ||
| 1266 | } | ||
| 1267 | |||
| 1246 | xs *user_setup_action = xs_fmt("%s/admin/user-setup", user->actor); | 1268 | xs *user_setup_action = xs_fmt("%s/admin/user-setup", user->actor); |
| 1247 | 1269 | ||
| 1248 | xs_html_add(top_controls, | 1270 | xs_html_add(top_controls, |
| @@ -1434,6 +1456,11 @@ xs_html *html_top_controls(snac *user) | |||
| 1434 | xs_html_text(metadata))), | 1456 | xs_html_text(metadata))), |
| 1435 | 1457 | ||
| 1436 | xs_html_tag("p", | 1458 | xs_html_tag("p", |
| 1459 | xs_html_text(L("Web interface language:")), | ||
| 1460 | xs_html_sctag("br", NULL), | ||
| 1461 | lang_select), | ||
| 1462 | |||
| 1463 | xs_html_tag("p", | ||
| 1437 | xs_html_text(L("New password:")), | 1464 | xs_html_text(L("New password:")), |
| 1438 | xs_html_sctag("br", NULL), | 1465 | xs_html_sctag("br", NULL), |
| 1439 | xs_html_sctag("input", | 1466 | xs_html_sctag("input", |
| @@ -4505,6 +4532,8 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 4505 | snac.config = xs_dict_set(snac.config, "show_contact_metrics", xs_stock(XSTYPE_TRUE)); | 4532 | snac.config = xs_dict_set(snac.config, "show_contact_metrics", xs_stock(XSTYPE_TRUE)); |
| 4506 | else | 4533 | else |
| 4507 | snac.config = xs_dict_set(snac.config, "show_contact_metrics", xs_stock(XSTYPE_FALSE)); | 4534 | snac.config = xs_dict_set(snac.config, "show_contact_metrics", xs_stock(XSTYPE_FALSE)); |
| 4535 | if ((v = xs_dict_get(p_vars, "web_ui_lang")) != NULL) | ||
| 4536 | snac.config = xs_dict_set(snac.config, "lang", v); | ||
| 4508 | 4537 | ||
| 4509 | snac.config = xs_dict_set(snac.config, "latitude", xs_dict_get_def(p_vars, "latitude", "")); | 4538 | snac.config = xs_dict_set(snac.config, "latitude", xs_dict_get_def(p_vars, "latitude", "")); |
| 4510 | snac.config = xs_dict_set(snac.config, "longitude", xs_dict_get_def(p_vars, "longitude", "")); | 4539 | snac.config = xs_dict_set(snac.config, "longitude", xs_dict_get_def(p_vars, "longitude", "")); |