--- /dev/null
+dnl Copyright © 2011 Nick Bowler
+dnl
+dnl Computes the set of .po and .mo files based on the LINGUAS environment
+dnl variable. The variable POFILES is set to the complete list of .po files,
+dnl according to the LINGUAS file in the po directory. The variable MOFILES
+dnl is set to the list of .mo files that the user has requested be installed.
+dnl Both POFILES and MOFILES are AC_SUBSTed.
+dnl
+dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
+dnl This is free software: you are free to do what the fuck you want to.
+dnl There is NO WARRANTY, to the extent permitted by law.
+
+AC_DEFUN([DX_LINGUAS], [dnl
+AC_REQUIRE([AM_GNU_GETTEXT])
+
+POFILES=
+MOFILES=
+
+if test -f "$srcdir/po/LINGUAS"; then
+ ALL_LINGUAS=`sed 's/#.*$//' "$srcdir/po/LINGUAS"`
+
+ : ${LINGUAS=all}
+ if test x"$LINGUAS" != x"all"; then
+ # Replicate la_CC-style codes as la.
+ LINGUAS=`printf '%s\n' "$LINGUAS" \
+ | [sed 's/\([^_[:space:]]*\)_[^[:space:]]*/& \1/g']`
+
+ printf '%s\n' $ALL_LINGUAS | sort > conftest.LINGUAS
+ LINGUAS=`printf '%s\n' $LINGUAS | sort \
+ | join - conftest.LINGUAS`
+ else
+ LINGUAS=$ALL_LINGUAS
+ fi
+
+ # Note: $srcdir is not used here because these variables are for make.
+ set x $ALL_LINGUAS; shift
+ case ${#} in
+ 0) ;;
+ *) POFILES=`printf "po/%s.po\n" "${@}"` ;;
+ esac
+
+ if test x"$USE_NLS" = x"yes"; then
+ set x $LINGUAS; shift
+ case ${#} in
+ 0) ;;
+ *) MOFILES=`printf "po/%s.mo\n" "${@}"` ;;
+ esac
+ fi
+fi
+
+AC_SUBST([POFILES])
+AC_SUBST([MOFILES])
+])