8af3b9
diff -up libpaper-1.1.24/lib/paper.c.useglibcfallback libpaper-1.1.24/lib/paper.c
8af3b9
--- libpaper-1.1.24/lib/paper.c.useglibcfallback	2010-04-24 08:12:11.000000000 -0400
8af3b9
+++ libpaper-1.1.24/lib/paper.c	2010-04-24 12:04:59.549538425 -0400
8af3b9
@@ -20,6 +20,9 @@
8af3b9
 
8af3b9
 #include <unistd.h>
8af3b9
 
8af3b9
+#include <locale.h>
8af3b9
+#include <langinfo.h>
8af3b9
+
8af3b9
 #include "paper.h"
8af3b9
 
8af3b9
 struct paper {
8af3b9
@@ -108,6 +111,27 @@ in PAPERCONFVAR, fall-back to the old be
8af3b9
 }
8af3b9
 
8af3b9
 const char* defaultpapername(void) {
8af3b9
+#if defined(LC_PAPER) && defined(_GNU_SOURCE)
8af3b9
+
8af3b9
+#define NL_PAPER_GET(x)         \
8af3b9
+  ((union { char *string; unsigned int word; })nl_langinfo(x)).word
8af3b9
+
8af3b9
+#define PT_TO_MM(v) (unsigned int)((v * 2.54 * 10 / 72) + 0.5)
8af3b9
+
8af3b9
+    const struct paper* pp;
8af3b9
+
8af3b9
+    unsigned int w = NL_PAPER_GET(_NL_PAPER_WIDTH);
8af3b9
+    unsigned int h = NL_PAPER_GET(_NL_PAPER_HEIGHT);
8af3b9
+
8af3b9
+    for (pp = paperfirst(); pp; pp = papernext(pp)) {
8af3b9
+	if (
8af3b9
+             PT_TO_MM(pp->pswidth) == w &&
8af3b9
+             PT_TO_MM(pp->psheight) == h
8af3b9
+           ) {
8af3b9
+	    return pp->name;
8af3b9
+	}
8af3b9
+    }
8af3b9
+#endif
8af3b9
     return PAPERSIZE;
8af3b9
 }
8af3b9
 
8af3b9
diff -up libpaper-1.1.24/man/paperconf.1.in.useglibcfallback libpaper-1.1.24/man/paperconf.1.in
8af3b9
--- libpaper-1.1.24/man/paperconf.1.in.useglibcfallback	2004-01-19 23:35:04.000000000 -0500
8af3b9
+++ libpaper-1.1.24/man/paperconf.1.in	2010-04-24 12:03:56.866532268 -0400
8af3b9
@@ -48,10 +48,12 @@ looking in order at the
8af3b9
 .B @PAPERSIZEVAR@
8af3b9
 environment variable, at the contents of the file specified by the
8af3b9
 .B @PAPERCONFVAR@
8af3b9
-environment variable, at the contects of
8af3b9
+environment variable, at the contents of the file
8af3b9
 .B @PAPERCONF@
8af3b9
-or by using
8af3b9
-.B letter
8af3b9
+, consulting the values controlled by the
8af3b9
+.B LC_PAPER
8af3b9
+locale setting, or by using
8af3b9
+.B @PAPERSIZE@
8af3b9
 as a fall-back value if none of the other alternatives are successful.
8af3b9
 By default, width and height of the paper are printed in PostScript points.
8af3b9
 .SH OPTIONS
8af3b9
diff -up libpaper-1.1.24/src/paperconf.c.useglibcfallback libpaper-1.1.24/src/paperconf.c
8af3b9
--- libpaper-1.1.24/src/paperconf.c.useglibcfallback	2007-09-26 02:13:38.000000000 -0400
8af3b9
+++ libpaper-1.1.24/src/paperconf.c	2010-04-24 12:03:56.867538135 -0400
8af3b9
@@ -13,6 +13,7 @@
8af3b9
 #include <errno.h>
8af3b9
 
8af3b9
 #include <paper.h>
8af3b9
+#include <locale.h>
8af3b9
 
8af3b9
 
8af3b9
 /* needed for GNU/Hurd */
8af3b9
@@ -99,6 +100,8 @@ int main(int argc, char** argv)
8af3b9
 
8af3b9
     const char* progname;
8af3b9
 
8af3b9
+    setlocale(LC_ALL, "");
8af3b9
+
8af3b9
     progname = strrchr(*argv, '/');
8af3b9
     if (progname) {
8af3b9
 	++progname;