aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2025-01-05 08:19:27 +0100
committerdefault <nobody@localhost>2025-01-05 08:19:27 +0100
commit79d8f5ff032e3d6cb5489f4b97be1987173b0e18 (patch)
tree9f7263cba9b143427998fe23acef19133dd51225 /main.c
parentb7ab926c25c27285fd6eb6e31258dc57979b157d (diff)
The 'note' cmdline looks at the LANG env var to set the post's language.
Diffstat (limited to 'main.c')
-rw-r--r--main.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/main.c b/main.c
index 76a7961..94d989c 100644
--- a/main.c
+++ b/main.c
@@ -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) {