glom r1729 - in branches/glom-1-8: . glom glom/libglom/data_structure glom/utility_widgets/db_adddel po
- From: murrayc svn gnome org
- To: svn-commits-list gnome org
- Subject: glom r1729 - in branches/glom-1-8: . glom glom/libglom/data_structure glom/utility_widgets/db_adddel po
- Date: Fri, 21 Nov 2008 14:36:48 +0000 (UTC)
Author: murrayc
Date: Fri Nov 21 14:36:48 2008
New Revision: 1729
URL: http://svn.gnome.org/viewvc/glom?rev=1729&view=rev
Log:
2008-11-21 Murray Cumming <murrayc murrayc com>
* glom/libglom/data_structure/glomconversions.[h|cc]:
Added sanity_check_date_parsing() and
sanity_check_date_text_representation_uses_4_digit_years().
* glom/main.cc: Use them to show informative warnings at startup.
The translators comment for %x mentions those warnings now too.
* po/es.po: Add a translation for %x because the es locales do not
use 4-digit years for this.
Ubuntu bug https://bugs.launchpad.net/ubuntu/+source/glom/+bug/300057
* glom/test_pyembed.cc: Add a cast to avoid a warning.
* glom/utility_widgets/db_adddel/db_adddel.cc: Initialize InnerIgnore
members to avoid warnings, though these would always be initialized in
real life.
Modified:
branches/glom-1-8/ChangeLog
branches/glom-1-8/glom/libglom/data_structure/glomconversions.cc
branches/glom-1-8/glom/libglom/data_structure/glomconversions.h
branches/glom-1-8/glom/main.cc
branches/glom-1-8/glom/test_pyembed.cc
branches/glom-1-8/glom/utility_widgets/db_adddel/db_adddel.cc
branches/glom-1-8/po/es.po
Modified: branches/glom-1-8/glom/libglom/data_structure/glomconversions.cc
==============================================================================
--- branches/glom-1-8/glom/libglom/data_structure/glomconversions.cc (original)
+++ branches/glom-1-8/glom/libglom/data_structure/glomconversions.cc Fri Nov 21 14:36:48 2008
@@ -51,7 +51,7 @@
return format_tm(tm_data, locale, "%T" /* I see no iso-format time in the list, but this looks like the standard C-locale format. murrayc*/);
}
else
- return format_tm(tm_data, locale, _("%X") /* time */);
+ return format_tm(tm_data, locale, "%X" /* time */);
}
Glib::ustring Conversions::format_date(const tm& tm_data)
@@ -63,7 +63,7 @@
static const char* glom_get_locale_date_format()
{
- /* TRANSLATORS: Please only translate this string if you know that strftime() shows only 2 year digits when using format "x". We want to always display 4 year digits. For instance, en_GB should translate it to "%d/%m/%Y". To discover if your locale has this problem, try the testdateput_allformats.cc test case in http://bugzilla.gnome.org/show_bug.cgi?id=334648. Thanks. */
+ /* TRANSLATORS: Please only translate this string if you know that strftime() shows only 2 year digits when using format "x". We want to always display 4 year digits. For instance, en_GB should translate it to "%d/%m/%Y". Glom will show a warning in the terminal at startup if this is necessary. Thanks. */
return _("%x");
}
@@ -78,6 +78,76 @@
}
}
+bool Conversions::sanity_check_date_parsing()
+{
+ //A date that is really really the date that we mean:
+ tm the_c_time;
+ memset(&the_c_time, 0, sizeof(the_c_time));
+
+ //We mean 22nd November 2008:
+ the_c_time.tm_year = 2008 - 1900; //C years start are the AD year - 1900. So, 01 is 1901.
+ the_c_time.tm_mon = 11 - 1; //C months start at 0.
+ the_c_time.tm_mday = 22; //starts at 1
+
+ //Get the current locale's text representation:
+ const Glib::ustring date_text = format_date(the_c_time);
+ //std::cout << "DEBUG: 22nd November 2008 in this locale has this text represention: " << date_text << std::endl;
+
+ //Try to parse it:
+ bool success = false;
+ tm parsed_date = parse_date(date_text, success);
+
+ if(success)
+ {
+ //std::cout << " DEBUG: parsed date: year=" << parsed_date.tm_year + 1900 << ", month=" << parsed_date.tm_mon + 1 << ", day=" << parsed_date.tm_mday << std::endl;
+ }
+
+ if(!success ||
+ parsed_date.tm_year != the_c_time.tm_year ||
+ parsed_date.tm_mon != the_c_time.tm_mon ||
+ parsed_date.tm_mday != the_c_time.tm_mday)
+ {
+ //Note to translators: If you see this error in the terminal at startup then you need to translate the %x elsewhere.
+ std::cerr << _("ERROR: sanity_check_date_parsing(): Sanity check failed: Glom could not parse a date's text representation that it generated itself, in this locale.") << std::endl;
+
+ //If translators cannot be relied upon to do this, maybe we should default to "%d/%m/%Y" when "%x" fails this test.
+
+ return false;
+ }
+
+ return true;
+}
+
+bool Conversions::sanity_check_date_text_representation_uses_4_digit_years()
+{
+ //A date that is really really the date that we mean:
+ tm the_c_time;
+ memset(&the_c_time, 0, sizeof(the_c_time));
+
+ //We mean 22nd November 2008:
+ the_c_time.tm_year = 2008 - 1900; //C years start are the AD year - 1900. So, 01 is 1901.
+ the_c_time.tm_mon = 11 - 1; //C months start at 0.
+ the_c_time.tm_mday = 22; //starts at 1
+
+ //Get the current locale's text representation:
+ const Glib::ustring date_text = format_date(the_c_time);
+ //std::cout << "DEBUG: 22nd November 2008 in this locale has this text represention: " << date_text << std::endl;
+
+ //See if the year appears in full in that date.
+ //There are probably some locales for which this fails.
+ //Please tell us if there are.
+ const Glib::ustring::size_type pos = date_text.find("2008");
+ if(pos == Glib::ustring::npos)
+ {
+ //Note to translators: If you see this error in the terminal at startup then you need to translate the %x elsewhere.
+ std::cerr << _("ERROR: sanity_check_date_text_represenation_uses_4_digit_year(): Sanity check failed: Glom does not seem to use 4 digits to display years in a date's text representation, in this locale.") << std::endl;
+
+ return false;
+ }
+
+ return true;
+}
+
Glib::ustring Conversions::format_tm(const tm& tm_data, const std::locale& locale, const char* format)
{
@@ -515,7 +585,7 @@
}
else
{
- std::cout << "DEBUG: Skipping std::time_get<> because it is incapable of parsing 4-digit years in the current locale." << std::endl;
+ //std::cout << "DEBUG: Skipping std::time_get<> because it is incapable of parsing 4-digit years in the current locale." << std::endl;
}
if(!skip_time_get && err != std::ios_base::failbit)
Modified: branches/glom-1-8/glom/libglom/data_structure/glomconversions.h
==============================================================================
--- branches/glom-1-8/glom/libglom/data_structure/glomconversions.h (original)
+++ branches/glom-1-8/glom/libglom/data_structure/glomconversions.h Fri Nov 21 14:36:48 2008
@@ -55,6 +55,21 @@
tm parse_time(const Glib::ustring& text, bool& success);
tm parse_time(const Glib::ustring& text, const std::locale& locale, bool& success);
+ /** Check that Glom can parse text representations of dates for which is has
+ * itself created the text representation.
+ * This may fail in some locales if a translation of the date format is missing.
+ *
+ * @result true if parsing is working.
+ */
+ bool sanity_check_date_parsing();
+
+ /** Check that Glom uses 4 digits to show years in text representations of dates.
+ * This may fail in some locales if a translation of the date format is missing.
+ *
+ * @result true if 4 digits are used.
+ */
+ bool sanity_check_date_text_representation_uses_4_digit_years();
+
Glib::ustring format_tm(const tm& tm_data, const std::locale& locale, const char* format);
//static tm parse_tm(const Glib::ustring& text, const std::locale& locale, char format);
Modified: branches/glom-1-8/glom/main.cc
==============================================================================
--- branches/glom-1-8/glom/main.cc (original)
+++ branches/glom-1-8/glom/main.cc Fri Nov 21 14:36:48 2008
@@ -27,6 +27,9 @@
#include <gtkmm/main.h>
#include <giomm.h>
+// For sanity checks:
+#include <glom/libglom/data_structure/glomconversions.h> // For GLOM_IMAGE_FORMAT
+
#ifndef GLOM_ENABLE_CLIENT_ONLY
#include <gtksourceviewmm/init.h>
#include <goocanvasmm/init.h>
@@ -265,6 +268,18 @@
if(!Glom::ConnectionPool::check_user_is_not_root())
return -1;
+
+ // Some more sanity checking:
+ // These print errors to the stdout if they fail.
+ // In future we might refuse to start if they fail.
+ const bool test1 = Glom::Conversions::sanity_check_date_parsing();
+ const bool test2 = Glom::Conversions::sanity_check_date_text_representation_uses_4_digit_years();
+ if(!test1 || !test2)
+ {
+ std::cerr << "Glom: ERROR: Date parsing sanity checks failed. Glom will not display dates correctly or interperet entered dates correctly. This needs attention from a translator. Please file a bug. See http://www.glom.org." << std::endl;
+ }
+
+
#ifdef GLIBMM_EXCEPTIONS_ENABLED
// Main app
Glib::RefPtr<Gnome::Glade::Xml> refXml = Gnome::Glade::Xml::create(Glom::Utils::get_glade_file_path("glom.glade"), "window_main");
Modified: branches/glom-1-8/glom/test_pyembed.cc
==============================================================================
--- branches/glom-1-8/glom/test_pyembed.cc (original)
+++ branches/glom-1-8/glom/test_pyembed.cc Fri Nov 21 14:36:48 2008
@@ -47,7 +47,7 @@
Py_Initialize();
- PyObject* pMain = PyImport_AddModule("__main__");
+ PyObject* pMain = PyImport_AddModule((gchar*)"__main__");
PyObject* pDict = PyModule_GetDict(pMain);
//Create the function definition:
Modified: branches/glom-1-8/glom/utility_widgets/db_adddel/db_adddel.cc
==============================================================================
--- branches/glom-1-8/glom/utility_widgets/db_adddel/db_adddel.cc (original)
+++ branches/glom-1-8/glom/utility_widgets/db_adddel/db_adddel.cc Fri Nov 21 14:36:48 2008
@@ -1349,9 +1349,10 @@
}
DbAddDel::InnerIgnore::InnerIgnore(DbAddDel* pOuter)
+: m_pOuter(pOuter),
+ m_bPreventUserSignals(false),
+ m_bIgnoreTreeViewSignals(false)
{
- m_pOuter = pOuter;
-
if(m_pOuter)
{
m_bPreventUserSignals = m_pOuter->get_prevent_user_signals();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]