glom r1730 - in branches/glom-1-8: . glom glom/libglom/data_structure



Author: murrayc
Date: Fri Nov 21 14:37:30 2008
New Revision: 1730
URL: http://svn.gnome.org/viewvc/glom?rev=1730&view=rev

Log:
2008-11-21  Murray Cumming  <murrayc murrayc com>

* glom/libglom/data_structure/glomconversions.c: 
sanity_check_date_text_representation_uses_4_digit_years(): 
Default to dd/mm/yyyy for dates when the translator has not provided 
a 4-digit-year date syntax for the locale, printing a warning that the 
default might not be suitable. This seems better than failing.

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

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:37:30 2008
@@ -61,10 +61,25 @@
 
 #define GLOM_NON_TRANSLATED_LOCALE_DATE_FORMAT "%x"
 
-static const char* glom_get_locale_date_format()
+// The % format to use to print and interpret dates, with 4-digit years:
+static const gchar* c_locale_date_format = 0;
+
+static inline 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". Glom will show a warning in the terminal at startup if this is necessary. Thanks. */
-  return _("%x");
+  if(!c_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". 
+     * Glom will show a warning in the terminal at startup if this is necessary 
+     * and default to %d/%m/%Y" if it detects a problem, but that might not be 
+     * correct for your locale.
+     * Thanks.
+     */
+    c_locale_date_format = _("%x");
+  }
+
+  return c_locale_date_format;
 }
 
 Glib::ustring Conversions::format_date(const tm& tm_data, const std::locale& locale, bool iso_format)
@@ -131,7 +146,7 @@
 
   //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;
+  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.
@@ -140,7 +155,12 @@
   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;
+    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. Defaulting to dd/mm/yyyy though this might be incorrect for your locale. This needs attention from a translator. Please file a bug - see http://www.glom.org";) << std::endl;
+
+    //Do not depend on translators to do what we ask.
+    //Default to a common format, though this would be incorrect in some 
+    //locales, such as German.
+    c_locale_date_format = "%d/%m/%Y";
 
     return false;
   }

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:37:30 2008
@@ -65,6 +65,8 @@
 
   /** 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.
+   * If it fails then Glom will default to using a dd/mm/yy format, which 
+   * might be incorrect for the locale.
    *
    * @result true if 4 digits are used.
    */

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:37:30 2008
@@ -272,8 +272,8 @@
     // 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();
+    const bool test1 = Glom::Conversions::sanity_check_date_text_representation_uses_4_digit_years();
+    const bool test2 = Glom::Conversions::sanity_check_date_parsing();
     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;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]