aboutsummaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2025-02-15 06:35:47 +0100
committerdefault <nobody@localhost>2025-02-15 06:35:47 +0100
commit1554a207e653d626c194b7d8113a55358c0dcdf7 (patch)
tree84fabbb1e475507add1b72bdbe555da56f84e68d /html.c
parent91d2beb267020fa632cace5b0b475a9febfa0439 (diff)
The interface language preference can now be set.
Diffstat (limited to 'html.c')
-rw-r--r--html.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/html.c b/html.c
index 5068b49..6573630 100644
--- a/html.c
+++ b/html.c
@@ -1243,6 +1243,28 @@ xs_html *html_top_controls(snac *user)
else
metadata = xs_str_new(NULL);
+ /* ui language */
+ xs_html *lang_select = xs_html_tag("select",
+ xs_html_attr("name", "web_ui_lang"));
+
+ const char *u_lang = xs_dict_get_def(user->config, "lang", "en");
+ const char *lang;
+ const xs_dict *langs;
+
+ xs_dict_foreach(srv_langs, lang, langs) {
+ if (strcmp(u_lang, lang) == 0)
+ xs_html_add(lang_select,
+ xs_html_tag("option",
+ xs_html_text(lang),
+ xs_html_attr("value", lang),
+ xs_html_attr("selected", "selected")));
+ else
+ xs_html_add(lang_select,
+ xs_html_tag("option",
+ xs_html_text(lang),
+ xs_html_attr("value", lang)));
+ }
+
xs *user_setup_action = xs_fmt("%s/admin/user-setup", user->actor);
xs_html_add(top_controls,
@@ -1434,6 +1456,11 @@ xs_html *html_top_controls(snac *user)
xs_html_text(metadata))),
xs_html_tag("p",
+ xs_html_text(L("Web interface language:")),
+ xs_html_sctag("br", NULL),
+ lang_select),
+
+ xs_html_tag("p",
xs_html_text(L("New password:")),
xs_html_sctag("br", NULL),
xs_html_sctag("input",
@@ -4505,6 +4532,8 @@ int html_post_handler(const xs_dict *req, const char *q_path,
snac.config = xs_dict_set(snac.config, "show_contact_metrics", xs_stock(XSTYPE_TRUE));
else
snac.config = xs_dict_set(snac.config, "show_contact_metrics", xs_stock(XSTYPE_FALSE));
+ if ((v = xs_dict_get(p_vars, "web_ui_lang")) != NULL)
+ snac.config = xs_dict_set(snac.config, "lang", v);
snac.config = xs_dict_set(snac.config, "latitude", xs_dict_get_def(p_vars, "latitude", ""));
snac.config = xs_dict_set(snac.config, "longitude", xs_dict_get_def(p_vars, "longitude", ""));