damned-lies r1152 - in trunk: . people po stats stats/management/commands



Author: claudep
Date: Sun Nov  9 22:04:30 2008
New Revision: 1152
URL: http://svn.gnome.org/viewvc/damned-lies?rev=1152&view=rev

Log:
Merge rev 1149 into trunk (committed in branch by error)

Added:
   trunk/po/README.translators
Modified:
   trunk/ChangeLog
   trunk/people/admin.py
   trunk/stats/management/commands/update-trans.py
   trunk/stats/models.py
   trunk/stats/utils.py

Modified: trunk/people/admin.py
==============================================================================
--- trunk/people/admin.py	(original)
+++ trunk/people/admin.py	Sun Nov  9 22:04:30 2008
@@ -1,4 +1,8 @@
 from django.contrib import admin
 from people.models import Person
 
-admin.site.register(Person)
+class PersonAdmin(admin.ModelAdmin):
+    search_fields = ('username', 'first_name', 'last_name')
+    list_display = ('username', 'first_name', 'last_name', 'email')
+
+admin.site.register(Person, PersonAdmin)

Added: trunk/po/README.translators
==============================================================================
--- (empty file)
+++ trunk/po/README.translators	Sun Nov  9 22:04:30 2008
@@ -0,0 +1,24 @@
+Damned-Lies is based on the Django framework. Thus it
+is not compatible with standard GNOME intltool toolchain.
+
+If you want to update a translation or begin a translation
+for a new language, pick the respective po/pot file
+through the Damned-Lies web interface.
+http://l10n.gnome.org/module/damned-lies
+
+For the curious, the pot file is generated with a special 
+wrapper script ('python manage.py update-trans en') and it needs
+a running Damned-Lies instance to get all strings (some are 
+in the database).
+Damned-Lies is based on the Django framework. Thus it
+is not compatible with standard GNOME intltool toolchain.
+
+If you want to update a translation or begin a translation
+for a new language, pick the respective po/pot file
+through the Damned-Lies web interface.
+http://l10n.gnome.org/module/damned-lies
+
+For the curious, the pot file is generated with a special 
+wrapper script ('python manage.py update-trans en') and it needs
+a running Damned-Lies instance to get all strings (some are 
+in the database).

Modified: trunk/stats/management/commands/update-trans.py
==============================================================================
--- trunk/stats/management/commands/update-trans.py	(original)
+++ trunk/stats/management/commands/update-trans.py	Sun Nov  9 22:04:30 2008
@@ -6,7 +6,7 @@
 import shutil
 
 class Command(BaseCommand):
-    help = "Update translations of djamnedlies"
+    help = "Update translations of djamnedlies ('en' is a special case, and generate damned-lies.pot)"
     args = "LANG_CODE"
     
     #option_list = BaseCommand.option_list + (
@@ -23,22 +23,24 @@
 
         # Copy po/ll.po in locale/ll/LC_MESSAGES/django.po
         podir = os.path.abspath('po')
-        pofile = os.path.join(podir, '%s.po' % lang_code)
-        if os.path.exists(pofile):
-            localedir = os.path.join(os.path.abspath('locale'), lang_code, 'LC_MESSAGES')
-            if not os.path.isdir(localedir):
-                os.makedirs(localedir)
-            shutil.copy(pofile, os.path.join(localedir, 'django.po'))
+        localedir = os.path.join(os.path.abspath('locale'), lang_code, 'LC_MESSAGES')
+        if lang_code != 'en':
+            pofile = os.path.join(podir, '%s.po' % lang_code)
+            if os.path.exists(pofile):
+                if not os.path.isdir(localedir):
+                    os.makedirs(localedir)
+                shutil.copy(pofile, os.path.join(localedir, 'django.po'))
+        else:
+            pofile = os.path.join(podir, 'damned-lies.pot')
         
         # Extract DB translatable strings into database-content.py
         dbfile = os.path.join(os.path.abspath('.'), 'database-content.py')
         f=open(dbfile, 'w')
         query = """SELECT description FROM team UNION DISTINCT
-                   SELECT name from `language` UNION DISTINCT
+                   SELECT name from `language` WHERE name <> locale UNION DISTINCT
                    SELECT description FROM domain UNION DISTINCT
-                   SELECT description FROM module UNION DISTINCT
-                   SELECT category FROM category UNION DISTINCT
-                   SELECT name from `release`;"""
+                   SELECT description FROM module WHERE description <> name UNION DISTINCT
+                   SELECT description FROM `release`;"""
         cursor = connection.cursor()
         cursor.execute(query)
         for row in cursor.fetchall():

Modified: trunk/stats/models.py
==============================================================================
--- trunk/stats/models.py	(original)
+++ trunk/stats/models.py	Sun Nov  9 22:04:30 2008
@@ -201,23 +201,31 @@
         domains = Domain.objects.filter(module=self.module)
         string_freezed = self.has_string_freezed()
         for dom in domains.all():
+            # 1. Initial settings
+            # *******************
             domain_path = os.path.join(self.co_path(), dom.directory)
             if not os.access(domain_path, os.X_OK):
                 # TODO: should check if existing stats, and delete (archive) them in this case
                 continue
             errors = []
-            if dom.dtype == 'ui':
+            
+            # 2. Pre-check, if available (intltool-update -m)
+            # **************************
+            if dom.dtype == 'ui'and not dom.pot_method:
                 # Run intltool-update -m to check for some errors
                 errors.extend(utils.check_potfiles(domain_path))
             
-            # Update pot file
+            # 3. Generate a fresh pot file
+            # ****************************
             if dom.dtype == 'ui':
-                potfile, errs = utils.generate_ui_pot_file(domain_path, dom.potbase(), settings.DEBUG)
-            elif dom.dtype == 'doc':
+                potfile, errs = dom.generate_pot_file(domain_path)
+            elif dom.dtype == 'doc': # only gnome-doc-utils toolchain supported so far for docs
                 potfile, errs = utils.generate_doc_pot_file(domain_path, dom.potbase(), self.module.name, settings.DEBUG)
                 doclinguas = utils.read_makefile_variable(domain_path, "DOC_LINGUAS").split()
             errors.extend(errs)
             
+            # 4. Compare with old pot files, various checks
+            # *****************************
             previous_pot = os.path.join(self.output_dir(dom.dtype), dom.potbase() + "." + self.name + ".pot")
             if not potfile:
                 if settings.DEBUG: print >> sys.stderr, "Can't generate POT file for %s/%s." % (self.module.name, dom.directory)
@@ -242,7 +250,9 @@
                 diff = potdiff.diff(previous_pot, potfile)
                 if not len(diff):
                     pot_has_changed = False
-                    
+            
+            # 5. Generate pot stats and update DB
+            # ***********************************
             pot_stats = utils.po_file_stats(potfile, 0)
             errors.extend(pot_stats['errors'])
 
@@ -260,8 +270,9 @@
             stat.save()
             for err in errors:
                 stat.information_set.add(Information(Type=err[0], Description=err[1]))
-                
-            # Update po files and update DB with new stats
+            
+            # 6. Update language po files and update DB
+            # *****************************************
             command = "msgmerge -o %(outpo)s %(pofile)s %(potfile)s"
             for lang, pofile in self.get_lang_files(dom, domain_path):
                 outpo = os.path.join(self.output_dir(dom.dtype), dom.potbase() + "." + self.name + "." + lang + ".po")
@@ -436,6 +447,10 @@
     description = models.TextField(null=True, blank=True)
     dtype = models.CharField(max_length=5, choices=DOMAIN_TYPE_CHOICES, default='ui')
     directory = models.CharField(max_length=50)
+    # The pot_method is a command who chould produce a potfile in the po directory of
+    # the domain, named <potbase()>.pot (e.g. /po/gnucash.pot). If blank, method is 
+    # intltool for UI and gnome-doc-utils for DOC
+    pot_method = models.CharField(max_length=50, null=True, blank=True)
 
     class Meta:
         db_table = 'domain'
@@ -452,6 +467,36 @@
     def get_description(self):
         return self.description or self.potbase()
     
+    def generate_pot_file(self, vcs_path):
+        """ Return the pot file generated, and the error if any """
+        
+        pot_command = self.pot_method
+        podir = vcs_path
+        if not self.pot_method: # default is intltool
+            pot_command = "intltool-update -g '%(domain)s' -p" % {'domain': self.potbase()}
+        elif self.module.name == 'damned-lies':
+            # special case for d-l, pot file should be generated from running instance dir
+            podir = "."
+            vcs_path = "./po"
+        command = "cd \"%(dir)s\" && %(pot_command)s" % {
+            "dir" : podir,
+            "pot_command" : pot_command,
+            }
+        if settings.DEBUG: print >>sys.stderr, command
+        (error, output) = commands.getstatusoutput(command)
+        if settings.DEBUG: print >> sys.stderr, output
+
+        potfile = os.path.join(vcs_path, self.potbase() + ".pot")
+
+        if error or not os.access(potfile, os.R_OK):
+            return "", (("error", ugettext_noop("Error regenerating POT file for %(file)s:\n<pre>%(cmd)s\n%(output)s</pre>")
+                                 % {'file': self.potbase(),
+                                    'cmd': command,
+                                    'output': output})
+                       )
+        else:
+            return potfile, ()
+    
 RELEASE_STATUS_CHOICES = (
     ('official', 'Official'),
     ('unofficial', 'Unofficial'),
@@ -691,10 +736,10 @@
 
 CATEGORY_CHOICES = (
     ('default', 'Default'),
-    ('admin-tools', 'Administration Tools'),
-    ('dev-tools', 'Development Tools'),
-    ('desktop', 'GNOME Desktop'),
-    ('dev-platform', 'GNOME developer platform'),
+    ('admin-tools', ugettext_noop('Administration Tools')),
+    ('dev-tools', ugettext_noop('Development Tools')),
+    ('desktop', ugettext_noop('GNOME Desktop')),
+    ('dev-platform', ugettext_noop('GNOME developer platform')),
 )
 class Category(models.Model):
     release = models.ForeignKey(Release)

Modified: trunk/stats/utils.py
==============================================================================
--- trunk/stats/utils.py	(original)
+++ trunk/stats/utils.py	Sun Nov  9 22:04:30 2008
@@ -72,26 +72,6 @@
                        + "</li>\n</ul>")))
     return errors
 
-def generate_ui_pot_file(vcs_path, potbase, verbose):
-    """ Return the pot file generated, and the error if any """
-    
-    command = "cd \"%(dir)s\" && intltool-update -g '%(domain)s' -p" % {
-        "dir" : vcs_path,
-        "domain" : potbase,
-        }
-    if verbose: print >>sys.stderr, command
-    (error, output) = commands.getstatusoutput(command)
-    if verbose: print >> sys.stderr, output
-
-    potfile = os.path.join(vcs_path, potbase + ".pot")
-
-    if error or not os.access(potfile, os.R_OK):
-        return "", (("error", ugettext_noop("Error regenerating POT file for %s:\n<pre>%s\n%s</pre>")
-                             % (potbase, command, output))
-                   )
-    else:
-        return potfile, ()
-
 def generate_doc_pot_file(vcs_path, potbase, moduleid, verbose):
     """ Return the pot file for a document-type domain, and the error if any """
     
@@ -119,8 +99,11 @@
     (error, output) = commands.getstatusoutput(command)
     if error:
         errors.append(("error",
-                       ugettext_noop("Error regenerating POT file for document %s:\n<pre>%s\n%s</pre>")
-                       % (potbase, command, output)))
+                       ugettext_noop("Error regenerating POT file for document %(file)s:\n<pre>%(cmd)s\n%(output)s</pre>")
+                             % {'file': potbase,
+                                'cmd': command,
+                                'output': output})
+                     )
     if verbose: print >> sys.stderr, output
     
     if error or not os.access(potfile, os.R_OK):



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