Index: dogtail/i18n.py
===================================================================
RCS file: /cvs/gnome/dogtail/dogtail/i18n.py,v
retrieving revision 1.3
diff -u -p -r1.3 i18n.py
--- dogtail/i18n.py	31 Oct 2005 22:21:41 -0000	1.3
+++ dogtail/i18n.py	3 Nov 2005 05:12:05 -0000
@@ -45,16 +45,31 @@ class GettextTranslationDb(TranslationDb
 	"""
 	def __init__(self, domainName):
 		self.domainName = domainName
-
-	def getTranslationsOf(self, srcName):
+	
+	def __getCandidateSourceStrings(self, srcName, prefix=None):
+		"""
+		Workaround for the fact that our scripts will contain something like:
+		"Forward" as a search string, but the translation might contain something
+		like "Navigation|_Forward" as a source string.
+		"""
+		
+		def makePrefixedString(srcName, prefix):
+			return "%s|%s"%(prefix, srcName)
+		
+		result = [srcName]
+		if prefix:
+			result.append(makePrefixedString(srcName, prefix))
+						
+		for index in range(len(srcName)):
+			candidate = srcName[:index]+"_"+srcName[index:]
+			result.append(candidate)
+			if prefix:
+				result.append(makePrefixedString(candidate, prefix))
+		return result
+		
+	def getTranslationsOf(self, srcName, prefix=None):
 		# print "searching for translations of %s"%srcName
 		# Use a dict to get uniqueness:
-		results = {}
-		result = gettext.dgettext(self.domainName, srcName)
-		#print "result in domain %s is %s"%(self.domainName, result)
-		if result!=srcName:
-			results[result]=None
-
 		# Hack alert:
 		#
 		# Note that typical UI definition in GTK etc contains strings with 
@@ -62,20 +77,20 @@ class GettextTranslationDb(TranslationDb
 		# For example, the stock GTK "Add" item has text "_Add" which e.g. 
 		# translates to "A_jouter" in French
 		#
+		# Note also that source strings can contain prefixes such as:
+		# "Navigation|_Forward" -> "_Avancer" in French
+		#
 		# Since these underscores have been stripped out before we see these strings,
 		# we are looking for a translation of "Add" into "Ajouter" in this case, so
 		# we need to fake it, by looking up the string multiple times, with underscores
 		# inserted in all possible positions, stripping underscores out of the result.  
 		# Ugly, but it works.
-			
-		for index in range(len(srcName)):
-			candidate = srcName[:index]+"_"+srcName[index:]
+		results = {}
+		for candidate in self.__getCandidateSourceStrings(srcName, prefix):
 			result = gettext.dgettext(self.domainName, candidate)
-			# print "result in domain %s for %s is %s"%(self.domainName, candidate, result)
+			print "result in domain %s is %s"%(self.domainName, result)
 			if result!=candidate:
-				# Strip out the underscore, and add to the result:
-				results[result.replace('_','')]=True
-			
+				results[result.replace('_','')]=True			
 		return results.keys()
 
 def translate(srcString):
@@ -200,8 +215,8 @@ def loadTranslationsFromPackageMoFiles(p
 	def load(packageName, getDependencies = True):
 		for domainName in getTranslationDomainsForPackage(packageName, getDependencies):
 			if domainName not in domains:
-				#if config.config.debugTranslation:
-				#	logger.log('Using translation domain "%s"'%domainName)
+				if config.config.debugTranslation:
+					logger.log('Using translation domain "%s"'%domainName)
 				translationDbs.append(GettextTranslationDb(domainName))
 				domains.append(domainName)
 				
