From 789345291b36ba4c382a531e7762c8bc98311166 Mon Sep 17 00:00:00 2001
From: Michael Carlberg <c@rlberg.se>
Date: Wed, 12 Oct 2016 16:48:14 +0200
Subject: [PATCH] fix(date): Use configured locale if defined

Fixes jaagr/lemonbuddy#74
---
 include/components/bar.hpp   | 1 +
 include/components/types.hpp | 2 ++
 include/modules/date.hpp     | 3 +++
 3 files changed, 6 insertions(+)

diff --git a/include/components/bar.hpp b/include/components/bar.hpp
index a8f40e6b..a4cd82f5 100644
--- a/include/components/bar.hpp
+++ b/include/components/bar.hpp
@@ -206,6 +206,7 @@ class bar : public xpp::event::sink<evt::button_press, evt::expose> {
     // Set misc parameters {{{
 
     m_bar.separator = string_util::trim(m_conf.get<string>(bs, "separator", ""), '"');
+    m_bar.locale = m_conf.get<string>(bs, "locale", "");
 
     // }}}
     // Checking nodraw {{{
diff --git a/include/components/types.hpp b/include/components/types.hpp
index 44312775..f6944c03 100644
--- a/include/components/types.hpp
+++ b/include/components/types.hpp
@@ -16,6 +16,8 @@ enum class gc { NONE = 0, BG, FG, OL, UL, BT, BB, BL, BR };
 struct bar_settings {
   bar_settings() = default;
 
+  string locale;
+
   int16_t x{0};
   int16_t y{0};
   uint16_t width{0};
diff --git a/include/modules/date.hpp b/include/modules/date.hpp
index e72c078d..6f51cc9f 100644
--- a/include/modules/date.hpp
+++ b/include/modules/date.hpp
@@ -10,6 +10,9 @@ namespace modules {
     using timer_module::timer_module;
 
     void setup() {
+      if (!m_bar.locale.empty())
+        setlocale(LC_TIME, m_bar.locale.c_str());
+
       m_interval = chrono::duration<double>(m_conf.get<float>(name(), "interval", 1));
 
       m_formatter->add(DEFAULT_FORMAT, TAG_DATE, {TAG_DATE});