diff options
| author | 2025-02-15 06:00:19 +0100 | |
|---|---|---|
| committer | 2025-02-15 06:00:19 +0100 | |
| commit | f0f93b84bec5373f9c6567b7b415ea77ca0bd064 (patch) | |
| tree | 5f653f221f9ebaacb7c50e3cd60b0147b45c0c13 /html.c | |
| parent | Some message tweaks. (diff) | |
| download | penes-snac2-f0f93b84bec5373f9c6567b7b415ea77ca0bd064.tar.gz penes-snac2-f0f93b84bec5373f9c6567b7b415ea77ca0bd064.tar.xz penes-snac2-f0f93b84bec5373f9c6567b7b415ea77ca0bd064.zip | |
Optimized lang_str().
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 17 |
1 files changed, 15 insertions, 2 deletions
| @@ -3326,6 +3326,17 @@ xs_str *html_notifications(snac *user, int skip, int show) | |||
| 3326 | } | 3326 | } |
| 3327 | 3327 | ||
| 3328 | 3328 | ||
| 3329 | void set_user_lang(snac *user) | ||
| 3330 | /* sets the language dict according to user configuration */ | ||
| 3331 | { | ||
| 3332 | user->lang = NULL; | ||
| 3333 | const char *lang = xs_dict_get(user->config, "lang"); | ||
| 3334 | |||
| 3335 | if (xs_is_string(lang)) | ||
| 3336 | user->lang = xs_dict_get(srv_langs, lang); | ||
| 3337 | } | ||
| 3338 | |||
| 3339 | |||
| 3329 | int html_get_handler(const xs_dict *req, const char *q_path, | 3340 | int html_get_handler(const xs_dict *req, const char *q_path, |
| 3330 | char **body, int *b_size, char **ctype, | 3341 | char **body, int *b_size, char **ctype, |
| 3331 | xs_str **etag, xs_str **last_modified) | 3342 | xs_str **etag, xs_str **last_modified) |
| @@ -3399,7 +3410,8 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 3399 | return HTTP_STATUS_NOT_FOUND; | 3410 | return HTTP_STATUS_NOT_FOUND; |
| 3400 | } | 3411 | } |
| 3401 | 3412 | ||
| 3402 | user = &snac; | 3413 | user = &snac; /* for L() */ |
| 3414 | set_user_lang(&snac); | ||
| 3403 | 3415 | ||
| 3404 | if (xs_is_true(xs_dict_get(srv_config, "proxy_media"))) | 3416 | if (xs_is_true(xs_dict_get(srv_config, "proxy_media"))) |
| 3405 | proxy = 1; | 3417 | proxy = 1; |
| @@ -4048,7 +4060,8 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 4048 | return HTTP_STATUS_UNAUTHORIZED; | 4060 | return HTTP_STATUS_UNAUTHORIZED; |
| 4049 | } | 4061 | } |
| 4050 | 4062 | ||
| 4051 | user = &snac; | 4063 | user = &snac; /* for L() */ |
| 4064 | set_user_lang(&snac); | ||
| 4052 | 4065 | ||
| 4053 | p_vars = xs_dict_get(req, "p_vars"); | 4066 | p_vars = xs_dict_get(req, "p_vars"); |
| 4054 | 4067 | ||