Commits

Zhang Huangbin committed 913d946

Use glob.glob() to fetch directory names of i18n translations.

Comments (0)

Files changed (1)

libs/ldaplib/admin.py

 # along with iRedAdmin-OSE.  If not, see <http://www.gnu.org/licenses/>.
 #---------------------------------------------------------------------
 
-import os, sys
+import sys
+import os
+import glob
 import ldap, ldap.filter
 import web
 from libs import languages, iredutils
     # Get available languages.
     def getLanguageMaps(self):
         # Get available languages.
-        self.available_langs = [ web.safestr(v)
-                for v in os.listdir(cfg.get('rootdir')+'i18n')
-                if v in languages.langmaps
+        self.available_langs = [ web.safestr(os.path.basename(v))
+                for v in glob.glob(cfg.get('rootdir')+'i18n/[a-z][a-z]_[A-Z][A-Z]')
+                if os.path.basename(v) in languages.langmaps
+                ]
+        self.available_langs += [ web.safestr(os.path.basename(v))
+                for v in glob.glob(cfg.get('rootdir')+'i18n/[a-z][a-z]')
+                if os.path.basename(v) in languages.langmaps
                 ]
         self.available_langs.sort()
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.