ProjectPyramid/Project.py

changeset 88
464745dfb03a
parent 83
f4d68a4248db
child 91
893e1f0baf23
equal deleted inserted replaced
87:673b87093f94 88:464745dfb03a
929 curProject = self.__currentProject 929 curProject = self.__currentProject
930 self.selectProjectAct.setText( 930 self.selectProjectAct.setText(
931 self.tr('&Current Pyramid Project ({0})').format(curProject)) 931 self.tr('&Current Pyramid Project ({0})').format(curProject))
932 932
933 if self.__currentProject is None: 933 if self.__currentProject is None:
934 self.__e5project.pdata["TRANSLATIONPATTERN"] = [] 934 try:
935 self.__e5project.setTranslationPattern("")
936 except AttributeError:
937 # backward compatibility
938 self.__e5project.pdata["TRANSLATIONPATTERN"] = []
935 else: 939 else:
936 lowerProject = self.__project().lower() 940 lowerProject = self.__project().lower()
937 config = configparser.ConfigParser() 941 config = configparser.ConfigParser()
938 config.read(os.path.join(self.__projectPath(), "setup.cfg")) 942 config.read(os.path.join(self.__projectPath(), "setup.cfg"))
939 try: 943 try:
942 outputDir = '{0}/locale'.format(lowerProject) 946 outputDir = '{0}/locale'.format(lowerProject)
943 try: 947 try:
944 domain = config.get("init_catalog", "domain") 948 domain = config.get("init_catalog", "domain")
945 except (configparser.NoOptionError, configparser.NoSectionError): 949 except (configparser.NoOptionError, configparser.NoSectionError):
946 domain = lowerProject 950 domain = lowerProject
947 self.__e5project.pdata["TRANSLATIONPATTERN"] = [ 951 try:
948 os.path.join(project, outputDir, "%language%", 952 self.__e5project.setTranslationPattern(
949 "LC_MESSAGES", "{0}.po".format(domain)) 953 os.path.join(project, outputDir, "%language%",
950 ] 954 "LC_MESSAGES", "{0}.po".format(domain))
955 )
956 except AttributeError:
957 # backward compatibility
958 self.__e5project.pdata["TRANSLATIONPATTERN"] = [
959 os.path.join(project, outputDir, "%language%",
960 "LC_MESSAGES", "{0}.po".format(domain))
961 ]
951 962
952 if self.__currentProject is None: 963 if self.__currentProject is None:
953 self.initializeDbAct.setEnabled(False) 964 self.initializeDbAct.setEnabled(False)
954 else: 965 else:
955 initCmd = self.__getInitDbCommand() 966 initCmd = self.__getInitDbCommand()
1332 Private method to extract the locale out of a file name. 1343 Private method to extract the locale out of a file name.
1333 1344
1334 @param filename name of the file used for extraction (string) 1345 @param filename name of the file used for extraction (string)
1335 @return extracted locale (string) or None 1346 @return extracted locale (string) or None
1336 """ 1347 """
1337 if self.__e5project.pdata["TRANSLATIONPATTERN"]: 1348 if self.__e5project.getTranslationPattern():
1338 # On Windows, path typically contains backslashes. This leads 1349 # On Windows, path typically contains backslashes. This leads
1339 # to an invalid seach pattern '...\(' because the opening bracked 1350 # to an invalid seach pattern '...\(' because the opening bracked
1340 # will be escaped. 1351 # will be escaped.
1341 pattern = self.__e5project.pdata["TRANSLATIONPATTERN"][0] 1352 pattern = self.__e5project.getTranslationPattern()
1342 pattern = os.path.normpath(pattern) 1353 pattern = os.path.normpath(pattern)
1343 pattern = pattern.replace("%language%", "(.*?)") 1354 pattern = pattern.replace("%language%", "(.*?)")
1344 pattern = pattern.replace('\\', '\\\\') 1355 pattern = pattern.replace('\\', '\\\\')
1345 match = re.search(pattern, filename) 1356 match = re.search(pattern, filename)
1346 if match is not None: 1357 if match is not None:
1467 " successfully.")) 1478 " successfully."))
1468 res = dia.startProcess(cmd, args, projectPath) 1479 res = dia.startProcess(cmd, args, projectPath)
1469 if res: 1480 if res:
1470 dia.exec_() 1481 dia.exec_()
1471 1482
1472 langFile = self.__e5project.pdata["TRANSLATIONPATTERN"][0]\ 1483 langFile = self.__e5project.getTranslationPattern()\
1473 .replace("%language%", code) 1484 .replace("%language%", code)
1474 self.__e5project.appendFile(langFile) 1485 self.__e5project.appendFile(langFile)
1475 1486
1476 def compileCatalogs(self, filenames): 1487 def compileCatalogs(self, filenames):
1477 """ 1488 """

eric ide

mercurial