[damned-lies] Allow for a LINGUAS file to be specified in linguas_location



commit 99a42117d9e4d161b993d84060fb13e3dae68fcd
Author: Claude Paroz <claude 2xlibre net>
Date:   Sat Jun 5 11:19:40 2010 +0200

    Allow for a LINGUAS file to be specified in linguas_location

 stats/models.py |    2 ++
 stats/utils.py  |   17 +++++++++--------
 2 files changed, 11 insertions(+), 8 deletions(-)
---
diff --git a/stats/models.py b/stats/models.py
index 4850c78..243573b 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -708,6 +708,8 @@ class Domain(models.Model):
             # Custom (or no) linguas location
             if self.linguas_location == 'no':
                 return {'langs':None, 'error':''}
+            elif self.linguas_location.split('/')[-1] == "LINGUAS":
+                return utils.read_linguas_file(os.path.join(base_path, self.linguas_location))
             else:
                 variable = "ALL_LINGUAS"
                 if "#" in self.linguas_location:
diff --git a/stats/utils.py b/stats/utils.py
index 7883430..77ed1bc 100644
--- a/stats/utils.py
+++ b/stats/utils.py
@@ -300,6 +300,14 @@ def po_file_stats(pofile, msgfmt_checks = True):
 
     return res
 
+def read_linguas_file(full_path):
+    """ Read a LINGUAS file (each language code on a line by itself) """
+    langs = []
+    lfile = open(full_path, "r")
+    [langs.extend(line.split()) for line in lfile if line[:1]!='#']
+    lfile.close()
+    return {'langs':langs,
+            'error': ugettext_noop("Entry for this language is not present in LINGUAS file.") }
 
 def get_ui_linguas(module_path, po_path):
     """Get language list in one of po/LINGUAS, configure.ac or configure.in"""
@@ -309,17 +317,10 @@ def get_ui_linguas(module_path, po_path):
     configureac = os.path.join(module_path, "configure.ac")
     configurein = os.path.join(module_path, "configure.in")
 
-    langs = []
-
     # is "lang" listed in either of po/LINGUAS, ./configure.ac(ALL_LINGUAS) or ./configure.in(ALL_LINGUAS)
     for LINGUAS in [LINGUAShere, LINGUASpo]:
         if os.access(LINGUAS, os.R_OK):
-            lfile = open(LINGUAS, "r")
-            [langs.extend(line.split()) for line in lfile if line[:1]!='#']
-            lfile.close()
-            return {'langs':langs,
-                    'error': ugettext_noop("Entry for this language is not present in LINGUAS file.") }
-
+            return read_linguas_file(LINGUAS)
     for configure in [configureac, configurein]:
         found = search_variable_in_file(configure, 'ALL_LINGUAS')
         if found is not None:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]