On Vr, 2008-09-19 at 00:01 +0200, Robert-André Mauchin wrote:
> Shaun McCance a écrit :
> > 
> > So the file looks like HTML, plus a plain text alternative,
> > and a few images, all packed into an mbox file.  Why can't
> > we just have source HTML and PNG files, and have a script
> > that automatically generated the mbox file?  Then we could
> > easily translate it with xml2po.
> > 
> > --
> > Shaun
> > 
> I was thinking that doing it at runtime would be very painful. Could we 
> generate theses Inbox files at build time with a simple shell script and 
> some gettext magic.
> We should add this script into POTFILES.in, and call it during make.
> 
> A draft is attached, but it would be good if a developer could do that 
> for us.
> 
> Regards

I had something similar in mind, but started out with Python. I _think_
(but will need some confirmation) that we'll need to do a little bit
more than this. Having the whole file as one unit in the PO file will
make it an extremely daunting task, especially to maintain in case of a
change in the English.

My idea is not complete at all, but I attach it as well. You'll see a
few extra goodies mentioned (some implemented), such as properly
encoding the header entries, so that we have valid from and subject
fields in the non-ASCII case. I also think we should try to avoid
translating the HTML and plain version separately. (Guess if I'm from a
small localisation team.)

The basic idea is using Inbox.in as a big Python string with variables
that are substituted in the strings.py program, that uses plain gettext
in Python, and therefore even supports translator comments. As a bonus
we could even generate the date of having a variable for the date at
build time to have it current instead of static in the file.

This is not yet integrated in the build system, but I guess somebody
might be able to help with that.

I hope it is of help somehow.

Keep well
Friedel
--
Recently on my blog:
http://translate.org.za/blogs/friedel/en/content/vrot-mango

Attachment: Inbox.in
Description: application/mbox

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2008 Friedel Wolff
#
# This file is part of Evolution.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.

from email.Header import Header

# TODO: implement to obtain the translations, either through traditional
# gettext, or otherwise. This will be run at build time, so we might not want
# to count on system-wide .mo files.
_ = lambda t: t


#TODO: put the current date in a variable so that we can use it as the sent date

header = {
        # The sender of the email
        "evo_team": _("The Evolution Team"),
        # The addressee
        "evo_users": _("Evolution Users"),
        # The email subject
        "welcome_to_evo": _("Welcome to Evolution!"),
}

# Properly encode headers. For more information, see
# http://www.python.org/doc/current/lib/module-email.header.html
for key in header.iterkeys():
    header[key] = Header(header[key], "utf-8")


body = {
        "welcome_intro": _("<B>The Evolution Team</B> is proud to welcome you to <B>Evolution</B>, a complete system for managing your communications and personal information."),
        "getting_started": _("Getting Started"),
}

def html2plain(text):
    # TODO: Strip HTML markup and do the text wrapping...
    return text

# Generate the plain text equivalents
for key in body.keys():
    body["plain_" + key] = html2plain(body[key])

_______________________________________________
gnome-i18n mailing list
gnome-i18n@gnome.org
http://mail.gnome.org/mailman/listinfo/gnome-i18n

Reply via email to