Skip to contentSkip to conversation

xend: drop XenAPI error message translation

PATCH In review Ian Campbell 2 participants 2 messages Apr 6, 2011 – Apr 8, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xend: drop XenAPI error message translation

# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1302107924 -3600
# Node ID 280e24d9f7001b0144e8873909f9f7ea6eff535c # Parent f90b78431d616f6119e05b863f965f8dc8e7dc92
xend: drop XenAPI error message translation

The only "translation" is to the C locale (e.g. the NUL translation). I think it very unlikely we are going to see any new translations of the XenAPI error messages at this point so the only purpose of this code appears to be to periodically regenerate xen-xm.pot with a new embedded timestamp, to the detriment of those of us who use a version control system.

After much beating with sticks I mananged to enable XenAPI support in xend and configure xm such that it returns "Permission denied." (AKA the SESSION_AUTHENTICATION_FAILED message) which I take to be a sign I've not broken things too badly.

tools/python/Makefile +4 -59
diff -r f90b78431d61 -r 280e24d9f700 tools/python/Makefile
@@ -4,22 +4,13 @@ include $(XEN_ROOT)/tools/Rules.mk
 .PHONY: all
 all: build
 
-# For each new supported translation, add its name here, eg 'fr_FR'
-# to cause the .po file to be built & installed, eg
-LINGUAS :=
-POPACKAGE := xen-xm
-PODIR := xen/xm/messages
-POTFILE := $(PODIR)/xen-xm.pot
-I18NSRCFILES = $(shell find xen/xm/ -name '*.py')
-CATALOGS = $(patsubst %,xen/xm/messages/%.mo,$(LINGUAS))
-NLSDIR = $(SHAREDIR)/locale
 XENPATH = "xen/util/path.py"
 
 genpath-target = $(call buildmakevars2file,$(XENPATH))
 $(eval $(genpath-target))
 
-.PHONY: build buildpy
-buildpy: genpath genwrap.py $(XEN_ROOT)/tools/libxl/libxl.idl \
+.PHONY: build
+build: genpath genwrap.py $(XEN_ROOT)/tools/libxl/libxl.idl \
 		$(XEN_ROOT)/tools/libxl/libxltypes.py
 	PYTHONPATH=$(XEN_ROOT)/tools/libxl $(PYTHON) genwrap.py \
 		$(XEN_ROOT)/tools/libxl/libxl.idl \
@@ -27,43 +18,8 @@ buildpy: genpath genwrap.py $(XEN_ROOT)/
 		xen/lowlevel/xl/_pyxl_types.c
 	CC="$(CC)" CFLAGS="$(CFLAGS)" $(PYTHON) setup.py build
 
-build: buildpy refresh-pot refresh-po $(CATALOGS)
-
-# NB we take care to only update the .pot file it strings have
-# actually changed. This is complicated by the embedded date
-# string, hence the sed black magic. This avoids the expensive
-# re-generation of .po files on every single build
-refresh-pot: $(I18NSRCFILES)
-	xgettext --default-domain=$(POPACKAGE) \
-		--keyword=N_ \
-		--keyword=_ \
-		-o $(POTFILE)-tmp \
-		$(I18NSRCFILES)
-	sed -f remove-potcdate.sed < $(POTFILE) > $(POTFILE)-1
-	sed -f remove-potcdate.sed < $(POTFILE)-tmp > $(POTFILE)-2
-	set -e; if cmp -s $(POTFILE)-1 $(POTFILE)-2; then \
-		rm -f $(POTFILE)-tmp $(POTFILE)-1 $(POTFILE)-2; \
-	else \
-		mv $(POTFILE)-tmp $(POTFILE); \
-                rm -f $(POTFILE)-1 $(POTFILE)-2; \
-	fi
-
-refresh-po: $(POTFILE)
-	set -e; for l in $(LINGUAS); do \
-		if $(MSGMERGE) $(PODIR)/$$l.po $(POTFILE) > $(PODIR)/$$l-tmp ; then \
-			mv -f $(PODIR)/$$l-tmp $(PODIR)/$$l.po ; \
-			echo "$(MSGMERGE) of $$l.po succeeded" ; \
-		else \
-			echo "$(MSGMERGE) of $$l.po failed" ; \
-			rm -f $(PODIR)/$$l-tmp ; \
-		fi \
-	done
-
-%.mo: %.po
-	$(MSGFMT) -c -o $@ $<
-
 .PHONY: install
-install: install-messages install-dtd
+install: install-dtd
 	CC="$(CC)" CFLAGS="$(CFLAGS)" $(PYTHON) setup.py install \
 		$(PYTHON_PREFIX_ARG) --root="$(DESTDIR)" --force
 
@@ -71,17 +27,6 @@ install-dtd: all
 	$(INSTALL_DIR) $(DESTDIR)$(SHAREDIR)/xen
 	$(INSTALL_DATA) xen/xm/create.dtd $(DESTDIR)$(SHAREDIR)/xen
 
-install-messages: all
-	set -e; if which $(MSGFMT) >/dev/null ; then \
-		$(INSTALL_DIR) $(DESTDIR)$(NLSDIR); \
-		for l in $(LINGUAS); do \
-			$(INSTALL_DIR) $(DESTDIR)$(NLSDIR)/$$l; \
-			$(INSTALL_DIR) $(DESTDIR)$(NLSDIR)/$$l/LC_MESSAGES; \
-			$(INSTALL_DATA) $(PODIR)/$$l.mo \
-				$(DESTDIR)$(NLSDIR)/$$l/LC_MESSAGES/$(POPACKAGE).mo; \
-		done ; \
-	fi
-
 .PHONY: test
 test:
 	export LD_LIBRARY_PATH=$$(readlink -f ../libxc):$$(readlink -f ../xenstore); $(PYTHON) test.py -b -u
@@ -89,7 +34,7 @@ test:
 .PHONY: clean
 clean:
 	rm -f $(XENPATH)
-	rm -rf build *.pyc *.pyo *.o *.a *~ $(CATALOGS) xen/util/auxbin.pyc
+	rm -rf *.pyc *.pyo *.o *.a *~ xen/util/auxbin.pyc
 	rm -f xen/lowlevel/xl/_pyxl_types.h
 	rm -f xen/lowlevel/xl/_pyxl_types.c
 	rm -f $(DEPS)
tools/python/remove-potcdate.sed deleted +0 -19
diff -r f90b78431d61 -r 280e24d9f700 tools/python/remove-potcdate.sed
@@ -1,19 +0,0 @@
-# Sed script that remove the POT-Creation-Date line in the header entry
-# from a POT file.
-#
-# The distinction between the first and the following occurrences of the
-# pattern is achieved by looking at the hold space.
-/^"POT-Creation-Date: .*"$/{
-x
-# Test if the hold space is empty.
-s/P/P/
-ta
-# Yes it was empty. First occurrence. Remove the line.
-g
-d
-bb
-:a
-# The hold space was nonempty. Following occurrences. Do nothing.
-x
-:b
-}
tools/python/xen/xm/XenAPI.py +11 -19
diff -r f90b78431d61 -r 280e24d9f700 tools/python/xen/xm/XenAPI.py
@@ -44,31 +44,23 @@
 # OF THIS SOFTWARE.
 # --------------------------------------------------------------------
 
-import gettext
 import xmlrpclib
 
 import xen.util.xmlrpcclient as xmlrpcclient
 
-def gettext_noop(str):
-    return str
-
-N_ = gettext_noop
-
 errormap = {
-    "INTERNAL_ERROR": N_("Internal error: %(1)s."),
-    "MAP_DUPLICATE_KEY": N_("This map already contains %(1)s -> %(2)s."),
-    "MESSAGE_METHOD_UNKNOWN": N_("The method %(1)s is unsupported."),
-    "MESSAGE_PARAMETER_COUNT_MISMATCH": N_("The method %(1)s takes %(2)s argument(s) (%(3)s given)."),
-    "SESSION_AUTHENTICATION_FAILED": N_("Permission denied."),
-    "VALUE_NOT_SUPPORTED": N_("Value \"%(2)s\" for %(1)s is not supported by this server.  The server said \"%(3)s\"."),
-    "HANDLE_INVALID": N_("The %(1)s handle %(2)s is invalid."),
-    "OPERATION_NOT_ALLOWED": N_("You attempted an operation that was not allowed."),
-    "NETWORK_ALREADY_CONNECTED": N_("The network you specified already has a PIF attached to it, and so another one may not be attached."),
-    "SECURITY_ERROR": N_("%(2)s"),
+    "INTERNAL_ERROR": "Internal error: %(1)s.",
+    "MAP_DUPLICATE_KEY": "This map already contains %(1)s -> %(2)s.",
+    "MESSAGE_METHOD_UNKNOWN": "The method %(1)s is unsupported.",
+    "MESSAGE_PARAMETER_COUNT_MISMATCH": "The method %(1)s takes %(2)s argument(s) (%(3)s given).",
+    "SESSION_AUTHENTICATION_FAILED": "Permission denied.",
+    "VALUE_NOT_SUPPORTED": "Value \"%(2)s\" for %(1)s is not supported by this server.  The server said \"%(3)s\".",
+    "HANDLE_INVALID": "The %(1)s handle %(2)s is invalid.",
+    "OPERATION_NOT_ALLOWED": "You attempted an operation that was not allowed.",
+    "NETWORK_ALREADY_CONNECTED": "The network you specified already has a PIF attached to it, and so another one may not be attached.",
+    "SECURITY_ERROR": "%(2)s",
     }
 
-translation = gettext.translation('xen-xm', fallback = True)
-
 class Failure(Exception):
     def __init__(self, details):
         try:
@@ -85,7 +77,7 @@ class Failure(Exception):
 
     def __str__(self):
         try:
-            return translation.ugettext(errormap[self.details[0]]) % self._details_map()
+            return errormap[self.details[0]] % self._details_map()
         except TypeError, exn:
             return "Message database broken: %s.\nXen-API failure: %s" % \
                    (exn, str(self.details))
tools/python/xen/xm/messages/en/xen-xm.po deleted +0 -93

94 lines not on this page · raw message

tools/python/xen/xm/messages/xen-xm.pot deleted +0 -68

68 lines not on this page · raw message

Acked-by on v1 1/1
#1 lore raw

Ian Campbell writes ("[Xen-devel] [PATCH] xend: drop XenAPI error message translation"):

Quoted 1 line

xend: drop XenAPI error message translation

...

Quoted 4 lines

After much beating with sticks I mananged to enable XenAPI support in xend and configure xm such that it returns "Permission denied." (AKA the SESSION_AUTHENTICATION_FAILED message) which I take to be a sign I've not broken things too badly.

It looks sane to me.