Need help with i18nizing some strings



Hi,

Right now we have a pretty ugly block of code:

        msgs = []
        if ins > 0:
            msgs.append("%d pending install%s" % (ins, (ins > 1 and "s") or ""))
        if rem > 0:
            msgs.append("%d pending removal%s" % (rem, (rem > 1 and "s") or ""))
        
        if (ins == 1 and rem == 0) or (ins == 0 and rem == 1):
            word = "is"
        else:
            word = "are"
        count_msg  = "There %s currently %s.  If you quit now, all pending " \
                     "operations will be lost." % (word, string.join(msgs, " and "))
        
        msg_lines = rcd_util.linebreak(count_msg, 40)
        msg_lines.append(_("Are you sure you want to quit?"))
        
which essentially allows us to get a string similar to:

        There are currently 2 pending installs and 1 pending removal. 
        If you quit now, all pending operations will be lost.
        Are you sure you want to quit?
        
Clearly this won't work for a lot of languages.  How can I refactor this
code to work nicely with all languages?  I guess there's also a more
general "what is the right way to do plurals" question here as well.

(Please CC me, I'm not on gnome-i18n)

Thanks,
Joe




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