24#include <boost/locale.hpp>
25#include "gnc-locale-utils.hpp"
45 return std::locale::classic();
47 static std::locale cached;
48 static bool tried_already =
false;
54 cached = std::locale(
"");
56 catch (
const std::runtime_error& err)
58 char* locale = g_strdup(setlocale(LC_ALL,
""));
60 g_log(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
61 "Failed to create C++ default locale from "
62 "%s because %s. Using the 'C' locale for C++.",
65 cached = std::locale::classic();
73static std::locale boost_cached;
74static bool tried_boost_already =
false;
77gnc_init_boost_locale (
const std::string& messages_path)
79 if (!tried_boost_already)
81 tried_boost_already =
true;
85 boost::locale::generator gen;
86 if (!messages_path.empty())
87 gen.add_messages_path(messages_path);
89 g_log(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
90 "Attempt to initialize boost_locale without a message_path. "
91 "If message catalogs are not installed in the system's default locations "
92 "user interface strings will not be translated.");
93 gen.add_messages_domain(PROJECT_NAME);
94 boost_cached = gen (
"");
96 catch (
const std::runtime_error& err)
98 const char* locale = setlocale(LC_ALL,
"");
100 g_log(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
101 "Failed to create C++ default locale from"
102 "%s because %s. Using the 'C' locale for C++.",
104 boost_cached = std::locale::classic();
112gnc_get_boost_locale()