ProjectDjango/Project.py

changeset 64
001e2a4e8677
parent 60
7ab44ea4ca4f
child 65
bceb78c1b1f0
--- a/ProjectDjango/Project.py	Thu Jan 01 13:24:56 2015 +0100
+++ b/ProjectDjango/Project.py	Mon Aug 15 17:36:22 2016 +0200
@@ -1598,12 +1598,23 @@
             self.tr('&Current Django project ({0})').format(curSite))
         
         if self.__currentSite is None:
-            self.__e5project.pdata["TRANSLATIONPATTERN"] = []
+            try:
+                self.__e5project.setTranslationPattern("")
+            except AttributeError:
+                # backward compatibility
+                self.__e5project.pdata["TRANSLATIONPATTERN"] = []
         else:
-            self.__e5project.pdata["TRANSLATIONPATTERN"] = [
-                os.path.join(site, "locale", "%language%", "LC_MESSAGES",
-                             "django.po")
-            ]
+            try:
+                self.__e5project.setTranslationPattern(
+                    os.path.join(site, "locale", "%language%", "LC_MESSAGES",
+                                 "django.po")
+                )
+            except AttributeError:
+                # backward compatibility
+                self.__e5project.pdata["TRANSLATIONPATTERN"] = [
+                    os.path.join(site, "locale", "%language%", "LC_MESSAGES",
+                                 "django.po")
+                ]
     
     def __site(self):
         """
@@ -2291,8 +2302,8 @@
         @param filename name of the file used for extraction (string)
         @return extracted locale (string) or None
         """
-        if self.__e5project.pdata["TRANSLATIONPATTERN"]:
-            pattern = self.__e5project.pdata["TRANSLATIONPATTERN"][0]\
+        if self.__e5project.getTranslationPattern():
+            pattern = self.__e5project.getTranslationPattern()\
                 .replace("%language%", "(.*?)")
             match = re.search(pattern, filename)
             if match is not None:
@@ -2370,7 +2381,7 @@
         if res:
             dia.exec_()
             
-            langFile = self.__e5project.pdata["TRANSLATIONPATTERN"][0]\
+            langFile = self.__e5project.getTranslationPattern()\
                 .replace("%language%", code)
             self.__e5project.appendFile(langFile)
     

eric ide

mercurial