Getting extended locale functions into use differs somewhat between platforms.
They could be checked separately, but it would make things more complicated.
This patch just tries to enable both variants simultaneously and see whether it
produces something usable.

Note: The BSD variant (xlocale.h) is untested and based only on the xlocale /
nl_langinfo_l manpage at http://developer.apple.com/documentation/Darwin/Reference/ManPages/man3/xlocale.3.html

nl_langinfo_l() is used always if present, even on Win32. Should all extended
locale related issues be !G_OS_WIN32 only, or will the check fail / code work
consistently?

	* configure.in: Check whether nl_langinfo_l() is available
	* gtk/gtkcalendar.c (locales_init): Use nl_langinfo_l() if available
	and get monthnames / weekday abbrevations from the locale defined by
	LC_MESSAGES (#343415)
---
 configure.in      |   21 +++++++++++++++++++++
 gtk/gtkcalendar.c |   33 ++++++++++++++++++++++++++++-----
 2 files changed, 49 insertions(+), 5 deletions(-)

Index: gtk/gtkcalendar.c
===================================================================
--- gtk/gtkcalendar.c.orig
+++ gtk/gtkcalendar.c
@@ -31,6 +31,13 @@
 
 #include <config.h>
 
+#ifdef HAVE_NL_LANGINFO_L
+#define _GNU_SOURCE	/* needed for GNU nl_langinfo_l */
+#include <locale.h>
+#include <langinfo.h>
+#include <xlocale.h>	/* needed for BSD nl_langinfo_l */
+#endif
+
 #ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
 #endif
@@ -378,16 +385,25 @@ locales_init (void)
 {
   gint i;
   char buffer[255];
-#ifdef G_OS_WIN32
-  wchar_t wbuffer[100];
-#else
+#ifdef HAVE_NL_LANGINFO_L
+  locale_t msglocale;
+#elif !defined(G_OS_WIN32)
   time_t tmp_time;
+#else
+  wchar_t wbuffer[100];
+#endif
+
+#ifdef HAVE_NL_LANGINFO_L
+  msglocale = newlocale (LC_TIME_MASK, setlocale (LC_MESSAGES, NULL), NULL);
 #endif
 
   if (!default_abbreviated_dayname[0])
     for (i=0; i<7; i++)
       {
-#ifndef G_OS_WIN32
+#ifdef HAVE_NL_LANGINFO_L
+	default_abbreviated_dayname[i] = g_locale_to_utf8 (nl_langinfo_l (ABDAY_1 + i, msglocale), -1,
+							   NULL, NULL, NULL);
+#elif !defined(G_OS_WIN32)
 	tmp_time= (i+3)*86400;
 	strftime ( buffer, sizeof (buffer), "%a", gmtime (&tmp_time));
 	default_abbreviated_dayname[i] = g_locale_to_utf8 (buffer, -1, NULL, NULL, NULL);
@@ -415,7 +431,10 @@ locales_init (void)
   if (!default_monthname[0])
     for (i=0; i<12; i++)
       {
-#ifndef G_OS_WIN32
+#ifdef HAVE_NL_LANGINFO_L
+	default_monthname[i] = g_locale_to_utf8 (nl_langinfo_l (MON_1 + i, msglocale), -1,
+						 NULL, NULL, NULL);
+#elif !defined(G_OS_WIN32)
 	tmp_time=i*2764800;
 	strftime ( buffer, sizeof (buffer), "%B", gmtime (&tmp_time));
 	default_monthname[i] = g_locale_to_utf8 (buffer, -1, NULL, NULL, NULL);
@@ -439,6 +458,10 @@ locales_init (void)
 	  }
 #endif
       }
+
+#ifdef HAVE_NL_LANGINFO_L
+  freelocale (msglocale);
+#endif
 }
 
 static void
Index: configure.in
===================================================================
--- configure.in.orig
+++ configure.in
@@ -416,6 +416,27 @@ if test "$gtk_ok" = "yes"; then
 	    [Define if _NL_TIME_FIRST_WEEKDAY is available])
 fi
 
+# Extended locale functions (nl_langinfo_l/newlocale/freelocale) have
+# (at least) two variants for taking into use
+AC_MSG_CHECKING([for nl_langinfo_l])
+AC_TRY_LINK([
+#define _GNU_SOURCE	/* needed for GNU nl_langinfo_l */
+#include <locale.h>
+#include <langinfo.h>
+#include <xlocale.h>	/* needed for BSD nl_langinfo_l */
+], [
+locale_t l;
+char *c;
+l = newlocale(LC_TIME_MASK, setlocale(LC_MESSAGES, NULL), NULL);
+c = nl_langinfo_l(ABDAY_1, l);
+freelocale(l);
+], [gtk_ok=yes], [gtk_ok=no])
+if test "$gtk_ok" = "yes"; then
+  AC_DEFINE([HAVE_NL_LANGINFO_L], [1],
+	    [Define if NL_LANGINFO_L is available])
+fi
+AC_MSG_RESULT($gtk_ok)
+
 # sigsetjmp is a macro on some platforms, so AC_CHECK_FUNCS is not reliable
 AC_MSG_CHECKING(for sigsetjmp)
 AC_TRY_LINK([#include <setjmp.h>], [
