# to "find" is required, to avoid including such directories in the
# list.
LOCALIZED_FILES=""
-for lfile in `find ${srcdir} -path './.??*' -prune -o -name '*.c' -type f -print || exit 1`; do
+for lfile in `find ${srcdir} -path './.??*' -prune -o -name '*.c' -print -o -name '*.py.in' -print || exit 1`; do
LOCALIZED_FILES="$LOCALIZED_FILES \$(TOPDIR)/$lfile"
done
AC_SUBST(LOCALIZED_FILES)
ifdef POTHEAD
XGETTEXT_FLAGS=\
- --language=C \
--keyword=_ \
--keyword=N_ \
--package-name=$(PKG_NAME) \
scrub.h \
workqueue.h
+GETTEXT_PY = \
+ gettext.py
+
LSRCFILES += gen_crc32table.c
LDIRT = gen_crc32table crc32table.h
-default: ltdepend $(LTLIBRARY)
+ifeq ($(ENABLE_GETTEXT),yes)
+HAVE_GETTEXT = True
+else
+HAVE_GETTEXT = False
+endif
+
+default: ltdepend $(LTLIBRARY) $(GETTEXT_PY)
crc32table.h: gen_crc32table.c crc32defs.h
@echo " [CC] gen_crc32table"
@echo " [GENERATE] $@"
$(Q) ./gen_crc32table > crc32table.h
+$(GETTEXT_PY): $(GETTEXT_PY).in $(TOPDIR)/include/builddefs
+ @echo " [SED] $@"
+ $(Q)$(SED) -e "s|@HAVE_GETTEXT@|$(HAVE_GETTEXT)|g" \
+ -e "s|@PACKAGE@|$(PKG_NAME)|g" \
+ -e "s|@LOCALEDIR@|$(PKG_LOCALE_DIR)|g" \
+ < $< > $@
+
include $(BUILDRULES)
install install-dev: default
--- /dev/null
+
+if __name__ == '__main__':
+ if @HAVE_GETTEXT@:
+ import gettext
+ # set up gettext before main so that we can set up _().
+ gettext.bindtextdomain("@PACKAGE@", "@LOCALEDIR@")
+ gettext.textdomain("@PACKAGE@")
+ _ = gettext.gettext
+ else:
+ def _(a):
+ return a
+
include $(BUILDRULES)
-$(XFS_PROTOFILE): $(XFS_PROTOFILE).in
+$(XFS_PROTOFILE): $(XFS_PROTOFILE).in $(TOPDIR)/include/builddefs $(TOPDIR)/libfrog/gettext.py
@echo " [SED] $@"
- $(Q)$(SED) -e "s|@pkg_version@|$(PKG_VERSION)|g" < $< > $@
+ $(Q)$(SED) -e "s|@pkg_version@|$(PKG_VERSION)|g" \
+ -e '/@INIT_GETTEXT@/r $(TOPDIR)/libfrog/gettext.py' \
+ -e '/@INIT_GETTEXT@/d' \
+ < $< > $@
$(Q)chmod a+x $@
install: default
# Walk a filesystem tree to generate a protofile for mkfs.
+@INIT_GETTEXT@
import os
import argparse
import sys
for fname in files:
if ' ' in fname:
- raise ValueError( \
- f'{fname}: Spaces not allowed in file names.')
+ msg = _("Spaces not allowed in file names.")
+ raise ValueError(f'{fname}: {msg}')
for fname in dirs:
if ' ' in fname:
- raise Exception( \
- f'{fname}: Spaces not allowed in file names.')
+ msg = _("Spaces not allowed in subdirectory names.")
+ raise Exception(f'{fname}: {msg}')
fname_width = max_fname_len(files)
for fname in files:
def main():
parser = argparse.ArgumentParser( \
- description = "Generate mkfs.xfs protofile for a directory tree.")
- parser.add_argument('paths', metavar = 'paths', type = str, \
- nargs = '*', help = 'Directory paths to walk.')
- parser.add_argument("-V", help = "Report version and exit.", \
+ description = _("Generate mkfs.xfs protofile for a directory tree."))
+ parser.add_argument('paths', metavar = _('paths'), type = str, \
+ nargs = '*', help = _('Directory paths to walk.'))
+ parser.add_argument("-V", help = _("Report version and exit."), \
action = "store_true")
args = parser.parse_args()
if args.V:
- print("xfs_protofile version @pkg_version@")
+ msg = _("xfs_protofile version")
+ pkgver = "@pkg_version@"
+ print(f"{msg} {pkgver}")
sys.exit(0)
emit_proto_header()