diff options
| author | default <nobody@localhost> | 2025-01-05 08:19:27 +0100 |
|---|---|---|
| committer | default <nobody@localhost> | 2025-01-05 08:19:27 +0100 |
| commit | 79d8f5ff032e3d6cb5489f4b97be1987173b0e18 (patch) | |
| tree | 9f7263cba9b143427998fe23acef19133dd51225 | |
| parent | b7ab926c25c27285fd6eb6e31258dc57979b157d (diff) | |
The 'note' cmdline looks at the LANG env var to set the post's language.
| -rw-r--r-- | main.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -669,6 +669,21 @@ int main(int argc, char *argv[]) msg = msg_note(&snac, content, NULL, NULL, attl, 0); + /* set a post language according the LANG environment variable */ + const char *lang_env = getenv("LANG"); + if (xs_type(lang_env) == XSTYPE_STRING) { + /* split at the first _ */ + xs *l0 = xs_split(lang_env, "_"); + const char *lang = xs_list_get(l0, 0); + + if (xs_type(lang) == XSTYPE_STRING && strlen(lang) == 2) { + /* a valid ISO language id */ + xs *cmap = xs_dict_new(); + cmap = xs_dict_set(cmap, lang, xs_dict_get(msg, "content")); + msg = xs_dict_set(msg, "contentMap", cmap); + } + } + c_msg = msg_create(&snac, msg); if (dbglevel) { |