Skip to content
Snippets Groups Projects
Unverified Commit 109d1f64 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

Multi-language support in notifier

parent ac9bd603
No related branches found
No related tags found
No related merge requests found
......@@ -37,14 +37,16 @@ else
exit 1
fi
message="$3"
message_cz="$3"
message_en="$4"
# This should be unique
msg_id="$(/bin/busybox date +%s)-$$"
mkdir -p "$base_dir"
mkdir "$base_dir/tmp.$msg_id"
echo "$severity" > "$base_dir/tmp.$msg_id/severity"
echo "$message" > "$base_dir/tmp.$msg_id/message"
echo "$message_cz" > "$base_dir/tmp.$msg_id/message_cz"
echo "$message_en" > "$base_dir/tmp.$msg_id/message_en"
mv "$base_dir/tmp.$msg_id" "$base_dir/$msg_id"
......
......@@ -18,6 +18,7 @@ mail_stamp="sent_by_email"
smtp_enabled=`uci get user_notify.smtp.enable`
mail_to=`uci get user_notify.smtp.to`
mail_from=`uci get user_notify.smtp.from`
lang="cz" # Auto-detect from system configuration somehow?
create_msmtp_config() {
local turris_smtp=`uci get user_notify.smtp.use_turris_smtp`
......@@ -131,19 +132,19 @@ compose_message() {
local msg_severity=`cat "$base_folder/$msg/severity"`
case "$msg_severity" in
"restart") echo -e "$(cat "$base_folder/$msg/message")\n" >> "$msg_file.restarts"
"restart") echo -e "$(cat "$base_folder/$msg/message_$lang")\n" >> "$msg_file.restarts"
echo "$msg" >> "$locker_stamp/stamps.restarts"
;;
"error") echo -e "$(cat "$base_folder/$msg/message")\n" >> "$msg_file.errors"
"error") echo -e "$(cat "$base_folder/$msg/message_$lang")\n" >> "$msg_file.errors"
echo "$msg" >> "$locker_stamp/stamps.errors"
;;
"update") echo -e "$(cat "$base_folder/$msg/message")\n" >> "$msg_file.updates"
"update") echo -e "$(cat "$base_folder/$msg/message_$lang")\n" >> "$msg_file.updates"
echo "$msg" >> "$locker_stamp/stamps.updates"
;;
"news") echo -e "$(cat "$base_folder/$msg/message")\n" >> "$msg_file.news"
"news") echo -e "$(cat "$base_folder/$msg/message_$lang")\n" >> "$msg_file.news"
echo "$msg" >> "$locker_stamp/stamps.news"
;;
"test") echo -e "$(cat "$base_folder/$msg/message")\n" >> "$msg_file.test"
"test") echo -e "$(cat "$base_folder/$msg/message_$lang")\n" >> "$msg_file.test"
echo "$msg" >> "$locker_stamp/stamps.test"
;;
*) echo "Unknown severity: $msg_severity"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment