nuxeo-localizer
[Top][All Lists]
Advanced

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

Re: [Nuxeo-localizer] Use of Catalog


From: Juan David Ibáñez Palomar
Subject: Re: [Nuxeo-localizer] Use of Catalog
Date: Fri, 07 Jun 2002 14:14:27 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0rc2) Gecko/20020520 Debian/1.0rc2-3

Err.. it's more simple than that, you don't need to create any
script..

Say "doc" is a LocalContent object:

 * if you type "doc.title" you'll get the title in the language
   that the language negotiation mechanism chooses, if you type
   "doc.getLocalAttribute('title')" you will get the same result;

 * if you type "doc.getLocalAttribute('title', 'fr') you'll get
   the title in french, if you type "doc.title_fr" you'll get
   the title in french too.

So, to index an object you should add to the Catalog the indexes
"title_en", "title_fr", "body_en", "body_fr" (for example). If it
doesn't works it's a bug.

The problem is that this is not well documented..



Garikoitz Araolaza wrote:

At 13:05 07/06/02, you wrote:

LocalContent is Catalogged after creation, but Vocabulary contains only words from title (only one language). Is there a possibility to search LocalContent objects by other Local properties? What should I do to enforce Catalog to search LocalContent by its multilingual content ?



Yes...

I usually do it this way:


1- Create Python Scripts in the root of your site, one per language:

text_en

And put inside:

    return '%s %s' % (context.title_en, context.body_en)

text_fr

    return '%s %s' % (context.title_fr, context.body_fr)

and so on...


Then, add  text_en, text_fr and so on as text indexes in your Catalog.

This way you will have different indexes depending on the language.

Now, you just have to do:

<dtml-call "REQUEST.set('text_en', your_variable_with_text_to_search)">
<dtml-in Catalog....>

</dtml-in>

In order to have only one method for all languages, you can first apply our Localizer Tip #1
http://www.zope.org/Members/CodeSyntax/DTML_Localizer

and once you've got SELECTED_LANGUAGE, then you can do:

<dtml-call "REQUEST.set('text_'+SELECTED_LANGUAGE, your_variable_with_text_to_search)">
<dtml-in Catalog....>

</dtml-in>

This way your user will always search in his selected language.

Gari

PS: yes... I know it's a little bit ugly, but... why don't you give a cleaner example? ;-)


_______________________________________
Garikoitz Araolaza
Code&Syntax
address@hidden

BIC-Berrilan
Azitaingo Industrialdea
E-20600-EIBAR
Tel: +34 943 82 06 06



_______________________________________________
Nuxeo-localizer mailing list
address@hidden
http://mail.freesoftware.fsf.org/mailman/listinfo/nuxeo-localizer



--
J. David Ibáñez, Nuxeo.com
Debian user (http://www.debian.org)






reply via email to

[Prev in Thread] Current Thread [Next in Thread]