[Zip] Message catalog interface

Juan David Ibáñez Palomar jdavid@nuxeo.com
Fri, 25 Jan 2002 15:02:34 +0100


Lennart Regebro wrote:

> From: "Juan David Ibáñez Palomar" <jdavid@nuxeo.com>
> 
>>   msg = ("We found ", Var("n"), " results searching for ", Var("term"))
>>   translation = message_catalog.get_translation(msg)
>>   text = interpolate(msg, {'n': '25', 'term': 'foo'})
>>
> 
> Oh, OK, I get it. Compared with %(foo)s this is more complicated to
> implement, less readable, harder to type in without errors and harder to
> spot errors, and much harder to translate.
> 
> The inline option is clearly the better one here. When it comes to the
> matter of which syntax to use, the %(foo)s can be used without any
> additional fuzz in python, so that seems to be the best one to me.
> 


I agree that for Python programmers, and from Python code,
Python formatted strings are better.

However, we also must think in ZPT. The 'string' expression
type of TALES has his own syntax:

   <span tal:content="string:My name is ${name}" />

And what if you want to translate this:

   <p>
     My name is <span tal:replace="here/name" />
   </p>

Here you could pass to the message catalog:

   - "My name is %(name)s"
   - "My name is ${name}"
   - ("My name is ", Var('name'))
   - ...

As you can see there're 2 important and related questions
we've to answer:

   1. The MC interface accepts strings, tuples or both?
   2. Page Templates send a tuple or a string to the MC?
      if a string, with which format?




> 
>>>OK, so the concept of source language exists only if you are using
>>>
> messages
> 
>>>and not id's.
>>>
>>Yes. But this doesn't means that you really need to say to
>>the message catalog in which language is your message, because
>>if it doesn't finds a translation it will return the message
>>and everything will work.
>>
> 
> Yup. Well, it seems to be a reasonable thing to do. On the other hand, it
> would be nice to get an error if a translation isn't found, för debugging.
> Or maybe that could just be written out as a warning with the logger, of
> course....
> 


Messages and translations are stored in message catalogs. If you
want to know how many messages have no translation in a language
just ask the message catalog.

Tools like KBabel for example show nice pictures with the amount
of messages translated, untranslated and fuzzy.

There isn't any need to show an error or a warning, no need for
debugging. Just go to the MC management interface and see what
remains to be translated.



jd