summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-05-11 23:55:58 +0200
committerCarl Hetherington <cth@carlh.net>2025-05-11 23:55:58 +0200
commit56456990549e91a949cb7a0912029ca0dc5973f6 (patch)
treea9ec917eaa45ba38d9ec63fe6d78e25152c5a02c
parent1f8c381fbd3c1b1aef7b5c7ff91c03e102c83a28 (diff)
More hax
-rw-r--r--src/lib/util.cc45
-rw-r--r--src/lib/util.h2
-rw-r--r--src/wx/colour_conversion_editor.cc3
-rw-r--r--src/wx/wx_util.cc2
4 files changed, 26 insertions, 26 deletions
diff --git a/src/lib/util.cc b/src/lib/util.cc
index 784178c08..bc74ae3dd 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -538,50 +538,49 @@ mo_path()
#endif
+/** Set things up so that gettext uses the given language for translation without
+ * altering the locale settings, in particular the decimal point.
+ *
+ * The idea is the language can be overridden but the decimal point is whatever
+ * is configured for the OS.
+ */
void
-dcpomatic_setup_gettext_i18n(string lang)
+dcpomatic_setup_c_and_gettext_i18n(string lang)
{
#ifdef DCPOMATIC_LINUX
lang += ".UTF8";
#endif
if (!lang.empty()) {
- /* Override our environment language. Note that the caller must not
- free the string passed into putenv().
- */
+ /* Override the environment that we want gettext to use. Note that
+ * the caller must not free the string passed into putenv().
+ */
string s = String::compose("LANGUAGE=%1", lang);
putenv(strdup(s.c_str()));
-#ifdef DCPOMATIC_WINDOWS
- /* On Windows this ensures that gettext i18n (for src/lib) works for the
- * "forced" language. On macOS doing this sets the number format to the
- * forced language, which means it disagrees with wxWidgets.
+#if defined(DCPOMATIC_WINDOWS) || defined(DCPOMATIC_LINUX)
+ /* On Linux and Windows this must not be "C" otherwise gettext doesn't work.
+ * https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html
+ *
+ * On macOS doing this sets the number format to the forced language, which
+ * means it disagrees with wxWidgets.
*/
s = String::compose("LANG=%1", lang);
putenv(strdup(s.c_str()));
#endif
-#ifdef DCPOMATIC_LINUX
- s = String::compose("LC_NUMERIC=%1", lang);
- putenv(strdup(s.c_str()));
-#endif
}
#ifndef DCPOMATIC_WINDOWS
- /* On Windows this seems to take us from the configured locale back to C,
- * which is never what we want. On macOS/Linux this has the opposite effect,
- * of making the configured language be applied to printf() etc.
- */
- setlocale(LC_ALL, "");
+ // /* On Windows this seems to take us from the configured locale back to C,
+ // * which is never what we want. On macOS/Linux this has the opposite effect
+ // * of making the configured language be applied to printf() etc.
+ // */
+ // setlocale(LC_ALL, "");
#endif
textdomain("libdcpomatic2");
-
-#if defined(DCPOMATIC_WINDOWS) || defined(DCPOMATIC_OSX)
bindtextdomain("libdcpomatic2", mo_path().string().c_str());
bind_textdomain_codeset("libdcpomatic2", "UTF8");
-#endif
-#ifdef DCPOMATIC_LINUX
- bindtextdomain("libdcpomatic2", LINUX_LOCALE_PREFIX);
-#endif
+ std::cout << "leaving setup with " << setlocale(LC_ALL, NULL) << " " << setlocale(LC_NUMERIC, NULL) << "\n";
}
/** Compute a digest of the first and last `size' bytes of a set of files. */
diff --git a/src/lib/util.h b/src/lib/util.h
index a463bf9bf..0d844085a 100644
--- a/src/lib/util.h
+++ b/src/lib/util.h
@@ -65,7 +65,7 @@ extern std::string seconds_to_approximate_hms(int);
extern double seconds(struct timeval);
extern void dcpomatic_setup();
extern void dcpomatic_setup_path_encoding();
-extern void dcpomatic_setup_gettext_i18n(std::string);
+extern void dcpomatic_setup_c_and_gettext_i18n(std::string);
extern std::string digest_head_tail(std::vector<boost::filesystem::path>, boost::uintmax_t size);
extern std::string simple_digest(std::vector<boost::filesystem::path> paths);
extern void ensure_ui_thread();
diff --git a/src/wx/colour_conversion_editor.cc b/src/wx/colour_conversion_editor.cc
index 6593b0b1d..4328f81fc 100644
--- a/src/wx/colour_conversion_editor.cc
+++ b/src/wx/colour_conversion_editor.cc
@@ -351,7 +351,8 @@ ColourConversionEditor::get () const
double blue_x = 0;
double blue_y = 0;
- std::cout << "from string for " << wx_to_std(_red_x->GetValue()) << " said " << wxNumberFormatter::FromString(_red_x->GetValue(), &red_x);
+ std::cout << "from string for " << wx_to_std(_red_x->GetValue()) << " said " << wxNumberFormatter::FromString(_red_x->GetValue(), &red_x) << "\n";
+ std::cout << "decimal separator is " << wxNumberFormatter::GetDecimalSeparator() << "\n";
wxNumberFormatter::FromString(_red_y->GetValue(), &red_y);
wxNumberFormatter::FromString(_green_x->GetValue(), &green_x);
wxNumberFormatter::FromString(_green_y->GetValue(), &green_y);
diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc
index 3f3b742af..d0f8f05b0 100644
--- a/src/wx/wx_util.cc
+++ b/src/wx/wx_util.cc
@@ -485,7 +485,7 @@ dcpomatic_setup_i18n()
wxTranslations::Set(translations);
- dcpomatic_setup_gettext_i18n(config_lang.get_value_or(""));
+ dcpomatic_setup_c_and_gettext_i18n(config_lang.get_value_or(""));
}
#else