[spambayes-dev] i18n revisited

Hernan Martínez Foffani hernan at orgmf.com.ar
Wed Nov 3 01:09:47 CET 2004

>> OTOH, you may check it in if you like.
>> I'll resync from HEAD and post in SF any future patch I make.
> I've gone with this.  I've checked it in as-is for the moment, and
> changes can be made against that - it'll make it easier to progress,
> I think, and those are more modifications (especially the doctest
> stuff) than additions.


>> Having an extra .mo is not a problem as long as their content
>> is very specific.  I thought of that for the dialogs.rc case.
> Is there a way to create a .pot file from several input files?

Just append the text pairs of msgid/msgstr.

> Conceptually, it would be better (I think) to have a .mo for Outlook
> and one for the other scripts, but I don't know how to combine the
> ones for (eg) sb_server.py and the ui.html stuff.

In my opinion gettext is more suitable to partition by applications
domains than logic ones.

>> Just *don't* use "_" in the places where we want to use the
>> alternative (in your proposal, only in
>> PyMeldLite.py:_GetTextNode.toText()) but the expanded gettext
>> call.
> gettext.gettext()?  (Sorry - I'm not sure what you mean - I'm very
> much new to this!)

Yes.  Actually, there is a way to keep using the "_" but then
i18n.py would need some rework.  From python docs:

  import gettext
  t = gettext.translation('logic_partition', ...)
  _ = t.gettext

A translation instance has an application domain and a
fallback language code list.  AFAIK, you can't modify the
application domain without reinstantiating the object.
We'll need a set of objects with the same lang list
but different application domain name.

The application domain is the string that corresponds
to the name of .mo file.

> [...]
> I'm happy to be outvoted here.  I guess we can build something to
> keep the ui.html's in sync if necessary...
> ...
> I'll work up a new patch with this system and post it here later
> today...

uh... I'm falling behind with the current thread.
Good! ;-)
I'll read your new patches and see if I can manage
to translate the html without screwing up everything.

> [Hernán Martínez Foffani]
>> Regarding the sb_server.py patch, I had also added the initialization
>> of the LanguageManager in the init() function but it failed later
>> when I tried to translate Options.py.  The addin delays the import
>> after the LanguageManager but sb_server.py does not.  We can either:
>>  1) Call LanguageManager at the very beginning of each main module.
>>     We have to be careful with the program flow and which imports
>>     whom to avoid NameError exceptions.
>>  2) Rebind "_" at i18n.py *import* time with, say:
>>       def _(x): return x
>>     or, better yet, installing the NullTranslation (same results)
>>     But I don't know if you use "_" at the command prompt too much.
> #2 sounds good to me, but, as I said, I'm new to this.  I never use
> '_' - but even if I did, that would only change behaviour if I (in an
> interactive session) did "from spambayes.i18n import _", right?



More information about the spambayes-dev mailing list