Beispiel #1
0
 def __init__(self, output):
     htmlpage.Htmlpage.__init__(self, None, output)
     write = self.writer
     if not write:
         return
     postats = data.load_postats()
     self.prologue("Textual domains", 'utf-8')
     write("<p>When looking for something to translate and wishing "
           "to reach the largest amount of users, one of the basic "
           "system tools is a good choice: grep, sed, tar, findutils, "
           "coreutils, and bash.  After those: "
           "xdg-user-dirs, parts of libc and parts of util-linux-ng.  "
           "And then maybe aspell, dialog, diffutils, e2fsprogs, gawk, "
           "kbd, make, psmisc, texinfo, wget, and xkeyboard-config. </p><br>\n")
     write('  <table id="domaintable">\n'
           '   <thead>\n'
           '   <tr class="left">\n'
           '    <th>Domain</th>\n'
           '    <th>Current version</th>\n'
           '    <th>Disclaimer required</th>\n'
           '    <th>Reference</th>\n'
           '   </tr>\n'
           '   </thead>\n'
           '   <tbody>\n')
     for domain in registry.domain_list():
         if domain.disclaim:
             myclass = "disclaim"
             word = "Yes"
         else:
             myclass = "nodisclaim"
             word = ""
         write('   <tr class="{}">\n'.format(myclass)+
               '    <td><a href="{0}.html">{0}</a></td>\n'.format(domain.name))
         if len(postats) and postats.potstats.has_key(domain.name):
             hints = registry.hints(postats.potstats[domain.name][0])
             write('    <td><a href="%s">%s</a></td>\n'
                   % (hints.template_url(), hints.version))
         else:
             write('    <td>-</td>\n')
             sys.stderr.write("  * No stats for '%s'\n" % domain.name)
         write('    <td>%s</td>\n' % (word))
         if domain.ref:
             write('    <td><a href="%s">%s</a></td>\n'
                   % (domain.ref[0][1], domain.ref[0][1]))
         else:
             write('    <td>--</td>\n')
         write('   </tr>\n')
     write('  </tbody>\n  </table>\n')
     self.epilogue()
Beispiel #2
0
def decode_database():
    import registry
    write = sys.stdout.write
    write("""\
<!-- Registry data for use in the Translation Project. -*- coding: utf-8 -*-
     Copyright © 2001, 2002 Translation Project.
     Copyright © 1996, 1997, 1998, 1999, 2000 Progiciels Bourbeau-Pinard inc.
     François Pinard `[email protected]', 1996.
-->

<!DOCTYPE registry SYSTEM "theregistry.dtd">
<registry>

 <domains>
""")
    for domain in registry.domain_list():
        write('\n')
        write(domain_description(domain))
    write("""\

 </domains>

 <teams>
""")
    for team in registry.team_list():
        write('\n')
        write(team_description(team))
    write("""\

 </teams>
</registry>

<!--
Local variables:
xxml-highlight-tag-alist: (("domains" . secondary-selection)
			   ("teams" . secondary-selection))
xxml-highlight-initial-alist: (("alias" . font-lock-type-face)
			       ("charset" . xxml-header-4-face)
			       ("code" . xxml-header-1-face)
			       ("disclaimer" . font-lock-comment-face)
			       ("do" . italic)
			       ("domain" . xxml-header-3-face)
			       ("leader" . xxml-header-4-face)
			       ("mailto" . font-lock-string-face)
			       ("nomailto" . font-lock-string-face)
			       ("package" . italic)
			       ("ref" . font-lock-builtin-face)
			       ("remark" . font-lock-comment-face)
			       ("team" . xxml-header-1-face)
			       ("translator" . font-lock-type-face)
			       ("url" . font-lock-string-face))
sgml-validate-command: "SP_CHARSET_FIXED=YES SP_ENCODING=utf-8 nsgmls -s %s %s"
sgml-omittag:t
sgml-shorttag:nil
sgml-omit-transparent:t
sgml-namecase-general:t
sgml-general-insert-case:lower
sgml-minimize-attributes:nil
sgml-always-quote-attributes:nil
sgml-indent-step:1
sgml-indent-data:nil
sgml-parent-document:nil
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->
""")
Beispiel #3
0
    def __init__(self, postats, team, output):
        htmlpage.Htmlpage.__init__(self, None, output)
        write = self.writer
        if not write:
            return
        self.prologue("Translation team for %s" % team.language, 'utf-8')
        assigned_domains = {}
        seen_translators = []
        write('  <p>The %s translation team uses <b><code>%s</code></b> as'
              ' its language code.  This code is part of the %s PO file'
              ' names.  It is also sometimes used as a short identification'
              ' for the team.</p>\n'
              % (team.language, team.code, team.language))

        write('  <p>\n')
        if team.mailto:
            write('   The team uses <a href="mailto:%s">%s</a> as official'
                  ' email address, which reaches either a mailing list or'
                  ' someone who broadcasts information to all other team'
                  ' members.\n'
                  % (team.mailto[0], team.mailto[0]))
        if team.leader and team.leader.mailto:
            name = uni2html(team.leader.uniname()[0],'utf-8')
            if team.leader.can_show_mail():
                write('   <a href="mailto:%s">%s</a>'
                      ' currently acts as the team leader,'
                      % (team.leader.mailto[0], name))
            elif team.leader.url:
                write('   <a href="%s">%s</a>'
                      ' currently acts as the team leader,'
                      % (team.leader.url[0], name))
            else:
                write('   %s currently acts as the team leader,' % name)
            write(' and you may write to him or her for all matters related'
                  ' to team coordination.\n')
        elif team.mailto:
            write('   The team does not seem to have appointed a leader, so'
                  ' for any questions you may write to the above team address.'
                  ' To get a package assigned, you can write directly to a'
                  ' <a href="mailto:[email protected]">'
                  'TP coordinator</a> while CC\'ing the team list.\n')
        else:
            write('   The team does not seem to have appointed a leader, so'
                  ' for any questions or to get a package assigned, you may'
                  ' write directly to a'
                  ' <a href="mailto:[email protected]">'
                  'TP coordinator</a>.\n')

        if team.charset:
            write('   Team members expressed a preference towards using the'
                  ' <code>%s</code> charset. '
                  ' You may want to consider using it whenever you send email'
                  ' to the team list or members, or if you produce any'
                  ' translation file meant for this team.\n'
                  % team.charset)
        write('  </p>\n')

        if team.ref:
            write('  <p>You can get more information about the'
                  ' %s effort here:</p>\n'
                  '  <table>\n'
                  '   <tr>\n'
                  '    <th>Topic</th>\n'
                  '    <th>URL</th>\n'
                  '   </tr>\n'
                  % team.language)
            for ref in team.ref:
                write('   <tr>\n'
                      '    <td>%s</td>\n'
                      '    <td align=left><a href="%s">%s</a></td>\n'
                      '   </tr>\n'
                      % (ref[0], ref[1], ref[1]))
            write('  </table>\n')
        write('  <p>The %s team currently consists of'
              ' the following translators:</p>\n'
              '  <table>\n'
              '   <tr>\n'
              '    <th>Translator</th>\n'
              '    <th>Assignments</th>\n'
              '    <th>Disclaimed</th>\n'
              '    <th>Autosend</th>\n'
              '   </tr>\n'
              % team.language)
        # Construct the table of translators.
        for name in team.translators:
            translator = registry.translator(team, name)
            domain_count = 0
            if translator.name[0] in seen_translators:
                continue
            seen_translators.append(translator.name[0])
            for domain in translator.do:
                if assigned_domains.has_key(domain.name):
                    sys.stderr.write("  * Domain multiply assigned: %s.%s\n"
                                     % (domain.name, team.name))
                assigned_domains[domain.name] = translator
                domain_count = domain_count + 1
            write('   <tr >\n'
                  '    <td align=left>%s</td>\n'
                  % translator_best_href(translator))
            if domain_count:
                write('    <td>%d</td>\n' % domain_count)
            else:
                write('    <td></td>\n')
            if translator.disclaimer:
                write('    <td>yes</td>\n')
            else:
                write('    <td></td>\n')
            if translator.autosend == "compress":
                write('    <td>compress</td>\n')
            elif translator.autosend:
                write('    <td>plain</td>\n')
            else:
                write('    <td>-</td>\n')
            write('   </tr>\n')
        write('  </table>\n')
        write('  <p>The Autosend column is for translators who want the PO'
              ' file sent to them when a new POT file is added to the project'
              ' -- they don\'t want to fetch the PO file themselves, but'
              ' wish to receive it together with the notice. '
              ' <a href="mailto:[email protected]">'
              'Just ask</a> if you want this service for yourself.</p>\n')
        write('  <p>Here is the current list of assignments of textual domains'
              ' to translators, as known to the Translation Project registry. '
              ' The robot relies on this information for directly accepting'
              ' submissions from translators. '
              ' The domains with a pinkish background'
              ' require that the translator has filled out a disclaimer;'
              ' those with a greenish background are freely translatable.'
              ' If you find some error or omission on this page, please write')
        if team.leader and team.leader.mailto and team.leader.can_show_mail():
            write(' to <a href="mailto:%s">%s</a> to get it corrected.</p>\n'
                  % (team.leader.mailto[0],
                     uni2html(team.leader.uniname()[0],'utf-8')))
        elif team.leader and team.leader.url:
            write(' to <a href="%s">%s</a> to get it corrected.</p>\n'
                  % (team.leader.url[0],
                     uni2html(team.leader.uniname()[0],'utf-8')))
        else:
            write(' to a <a href="mailto:[email protected]">'
                  'TP coordinator</a> to get it corrected.</p>\n')
        write('  <table>\n'
              '   <tr>\n'
              '    <th>Domain</th>\n'
              '    <th>Last<br>known<br>version</th>\n'
              '    <th>&nbsp;Translated&nbsp;</th>\n'
              '    <th>&nbsp;Assigned&nbsp;translator&nbsp;</th>\n'
              '   </tr>\n')
        # Construct the table of packages.
        for domain in registry.domain_list():
            if domain.disclaim:
                hue = "#fff3f3"
            else:
                hue = "#f3fff3"
            write('   <tr>\n'
                  '    <td align=left bgcolor="%s">'
                  '<a href="../domain/%s.html">%s</a></td>\n'
                  % (hue, domain.name, domain.name))
            extstats = None
            file = '%s/%s/%s.po' % (config.last_path, domain.name, team.name)
            try:
                if len(postats):
                    template, tally = postats.potstats[domain.name]
                else:
                    template = ""
                version = registry.hints(template).version
            except KeyError:
                version = None
            if version:
                key = domain.name, version.name, team.name
                if team.code in domain.ext:
                    reference = '%s' % version
                    if os.path.isfile(file):
                        color = "#f8d0f8"  # Magenta: external but file present.
                    else:
                        color = "#e8e8e8"  # Grey: external.
                    if extstats:
                        numbers = ("%d / %d" % (extstats['translated'], tally))
                    else:
                        numbers = "unknown"
                elif postats.has_key(key):
                    reference = ('<a href="../%s/%s/%s-%s.%s.po">%s</a>'
                                 % (config.pos_dir, team.name,
                                    domain.name, version, team.name, version))
                    translated = postats[key][2]
                    fuzzy = postats[key][7]
                    total = tally
                    color = colorize(translated, tally)
                    numbers = '    <td bgcolor="%s"><span class="statpercent">%d%%</span> <span class="stattrans">%d</span> <span class="statfuzzy">%d</span> <span class="statun">%d</span> \n' % (colorize(translated, total), 100*translated/total, translated, fuzzy, total-fuzzy-translated)

                    T=100*translated/total
                    F=100*fuzzy/total
                    U=100-T-F

                    numbers +='  <div class="graph">\n'
                    numbers +='    <div class="translated"   style="width: %dpx;">  </div>\n' % (T)
                    numbers +='    <div class="fuzzy"        style="left: %dpx; width: %dpx;"></div>\n' % (T, F)
                    numbers +='    <div class="untranslated" style="left: %dpx; width: %dpx;"></div>\n' % ((T+F), U)
                    numbers +='  </div></td>\n'


                else:
                    reference = ('<a href="../%s/%s-%s.pot">%s</a>'
                                 % (config.pots_dir, domain.name, version,
                                    version))
                    color = "#d0f0f8"  # Blue: fully untranslated.
                    translated=0
                    fuzzy=0
                    total=tally
                    numbers = '    <td bgcolor="%s"><span class="statpercent">%d%%</span> <span class="stattrans">%d</span> <span class="statfuzzy">%d</span> <span class="statun">%d</span> \n' % (colorize(translated, total), 100*translated/total, translated, fuzzy, total-fuzzy-translated)

                    T=100*translated/total
                    F=100*fuzzy/total
                    U=100-T-F

                    numbers +='  <div class="graph">\n'
                    numbers +='    <div class="translated"   style="width: %dpx;">  </div>\n' % (T)
                    numbers +='    <div class="fuzzy"        style="left: %dpx; width: %dpx;"></div>\n' % (T, F)
                    numbers +='    <div class="untranslated" style="left: %dpx; width: %dpx;"></div>\n' % ((T+F), U)
                    numbers +='  </div></td>\n'
                write('    <td>%s</td>\n'
                      '    %s\n'
                      % (reference, numbers))
            else:
                write('    <td colspan=2></td>\n')
            if assigned_domains.has_key(domain.name):
                write('    <td align=left>%s</td>\n'
                      % translator_best_href(assigned_domains[domain.name]))
            elif team.code in domain.ext:
                write('    <td bgcolor="#e8e8e8"><i>external</i></td>\n')
                extstats = get_extstats().get((domain.name, team.code))
            else:
                write('    <td></td>\n')
            write('   </tr>\n')
        write('  </table>\n')
        self.epilogue()