blam r564 - trunk/src



Author: cmartin
Date: Fri Apr 25 17:07:43 2008
New Revision: 564
URL: http://svn.gnome.org/viewvc/blam?rev=564&view=rev

Log:
Make the date string shown on the ItemView localized.


Modified:
   trunk/src/ItemView.cs

Modified: trunk/src/ItemView.cs
==============================================================================
--- trunk/src/ItemView.cs	(original)
+++ trunk/src/ItemView.cs	Fri Apr 25 17:07:43 2008
@@ -105,9 +105,33 @@
         {
 			Theme theme = Application.TheApp.ThemeManager.CurrentTheme;
 
+            /* One of the variables should be set. */
+            string locale = Environment.GetEnvironmentVariable("LC_MESSAGES");
+
+            if(locale == null){
+                locale = Environment.GetEnvironmentVariable("LC_ALL");
+            }
+            if(locale == null){
+                locale = Environment.GetEnvironmentVariable("LC_TIME");
+            }
+            if(locale == null){
+                locale = Environment.GetEnvironmentVariable("LANGUAGE");
+            }
+            if(locale == null){
+                locale = Environment.GetEnvironmentVariable("LANG");
+            }
+            if(locale == null){
+                locale = "en"; /* Give up. */
+            }
+
+            if(locale.IndexOf('_') != -1){ /* There is a separator. Do en_US.UTF-8 -> en, eg.*/
+                locale = locale.Substring(0, locale.IndexOf('_'));
+            }
+
             string author  = (!"".Equals(currentItem.Author)) ? String.Format(Catalog.GetString("by {0}"), currentItem.Author) : " ";
             string link    = Catalog.GetString("Show in browser");
-            string pubdate = (!currentItem.PubDate.Equals(DateTime.MinValue)) ? currentItem.PubDate.ToLongDateString() : " ";
+            string pubdate = (!currentItem.PubDate.Equals(DateTime.MinValue)) ?
+                currentItem.PubDate.ToString("D", System.Globalization.CultureInfo.CreateSpecificCulture(locale)) : " ";
             string text    = HtmlUtils.EncodeUnicode(HtmlUtils.FixMarkup(currentItem.Text));
             string title   = HtmlUtils.Escape(currentItem.Title);
             string url     = currentItem.Link;



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