ProjectDjango/Project.py

changeset 64
001e2a4e8677
parent 60
7ab44ea4ca4f
child 65
bceb78c1b1f0
equal deleted inserted replaced
60:7ab44ea4ca4f 64:001e2a4e8677
1596 curSite = self.__currentSite 1596 curSite = self.__currentSite
1597 self.selectSiteAct.setText( 1597 self.selectSiteAct.setText(
1598 self.tr('&Current Django project ({0})').format(curSite)) 1598 self.tr('&Current Django project ({0})').format(curSite))
1599 1599
1600 if self.__currentSite is None: 1600 if self.__currentSite is None:
1601 self.__e5project.pdata["TRANSLATIONPATTERN"] = [] 1601 try:
1602 self.__e5project.setTranslationPattern("")
1603 except AttributeError:
1604 # backward compatibility
1605 self.__e5project.pdata["TRANSLATIONPATTERN"] = []
1602 else: 1606 else:
1603 self.__e5project.pdata["TRANSLATIONPATTERN"] = [ 1607 try:
1604 os.path.join(site, "locale", "%language%", "LC_MESSAGES", 1608 self.__e5project.setTranslationPattern(
1605 "django.po") 1609 os.path.join(site, "locale", "%language%", "LC_MESSAGES",
1606 ] 1610 "django.po")
1611 )
1612 except AttributeError:
1613 # backward compatibility
1614 self.__e5project.pdata["TRANSLATIONPATTERN"] = [
1615 os.path.join(site, "locale", "%language%", "LC_MESSAGES",
1616 "django.po")
1617 ]
1607 1618
1608 def __site(self): 1619 def __site(self):
1609 """ 1620 """
1610 Private method to get the name of the current site. 1621 Private method to get the name of the current site.
1611 1622
2289 Private method to extract the locale out of a file name. 2300 Private method to extract the locale out of a file name.
2290 2301
2291 @param filename name of the file used for extraction (string) 2302 @param filename name of the file used for extraction (string)
2292 @return extracted locale (string) or None 2303 @return extracted locale (string) or None
2293 """ 2304 """
2294 if self.__e5project.pdata["TRANSLATIONPATTERN"]: 2305 if self.__e5project.getTranslationPattern():
2295 pattern = self.__e5project.pdata["TRANSLATIONPATTERN"][0]\ 2306 pattern = self.__e5project.getTranslationPattern()\
2296 .replace("%language%", "(.*?)") 2307 .replace("%language%", "(.*?)")
2297 match = re.search(pattern, filename) 2308 match = re.search(pattern, filename)
2298 if match is not None: 2309 if match is not None:
2299 loc = match.group(1) 2310 loc = match.group(1)
2300 return loc 2311 return loc
2368 "\nMessage catalog initialized successfully.")) 2379 "\nMessage catalog initialized successfully."))
2369 res = dia.startProcess(args, wd) 2380 res = dia.startProcess(args, wd)
2370 if res: 2381 if res:
2371 dia.exec_() 2382 dia.exec_()
2372 2383
2373 langFile = self.__e5project.pdata["TRANSLATIONPATTERN"][0]\ 2384 langFile = self.__e5project.getTranslationPattern()\
2374 .replace("%language%", code) 2385 .replace("%language%", code)
2375 self.__e5project.appendFile(langFile) 2386 self.__e5project.appendFile(langFile)
2376 2387
2377 def updateSelectedCatalogs(self, filenames): 2388 def updateSelectedCatalogs(self, filenames):
2378 """ 2389 """

eric ide

mercurial