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