Sorry, Tibor,

forget the previous patch, it is old; I forgot a 'quilt refresh' ;-(

may you consider this patch for inclusion for next release?
You can see what I'm trying to fix looking at our "Search
collections:" pull down menu in, for example:

http://ddd.uab.es/search.py?sc=1&ln=en&p=&f=&action=Search&cc=rcao

New one is attached.

Ferran
With this patch (tested on 0.91.0.20061116) i18n collection names
are honored.  It is specially important if default collection names
are coded, because they appear short and cryptic for the end user.


Index: cds-invenio-0.91.0.20061116/modules/websearch/lib/search_engine.py
===================================================================
--- cds-invenio-0.91.0.20061116.orig/modules/websearch/lib/search_engine.py	2006-11-10 12:22:39.000000000 +0100
+++ cds-invenio-0.91.0.20061116/modules/websearch/lib/search_engine.py	2006-11-30 12:16:47.000000000 +0100
@@ -125,15 +125,16 @@
 sre_unicode_uppercase_c = sre.compile(unicode(r"(?u)[??]", "utf-8"))
 sre_unicode_uppercase_n = sre.compile(unicode(r"(?u)[?]", "utf-8"))
 
-def get_alphabetically_ordered_collection_list(level=0):
+def get_alphabetically_ordered_collection_list(ln, level=0):
     """Returns nicely ordered (score respected) list of collections, more exactly list of tuples
        (collection name, printable collection name).
        Suitable for create_search_box()."""
     out = []
-    query = "SELECT id,name FROM collection ORDER BY name ASC"
+    query = "SELECT name FROM collection ORDER BY name ASC"
     res = run_sql(query)
-    for c_id, c_name in res:
-        # make a nice printable name (e.g. truncate c_printable for for long collection names):
+    for name in res:
+        # make a nice printable name (e.g. truncate c_printable for long collection names in language ln):
+        c_name = get_coll_i18nname(name, ln)
         if len(c_name)>30:
             c_printable = c_name[:30] + "..."
         else:
@@ -143,7 +144,7 @@
         out.append([c_name, c_printable])
     return out
 
-def get_nicely_ordered_collection_list(collid=1, level=0):
+def get_nicely_ordered_collection_list(ln, collid=1, level=0):
     """Returns nicely ordered (score respected) list of collections, more exactly list of tuples
        (collection name, printable collection name).
        Suitable for create_search_box()."""
@@ -152,7 +153,8 @@
             " WHERE c.id=cc.id_son AND cc.id_dad='%s' ORDER BY score DESC" % collid
     res = run_sql(query)
     for c, cid in res:
-        # make a nice printable name (e.g. truncate c_printable for for long collection names):
+        # make a nice printable name (e.g. truncate c_printable for long collection names in language ln):
+        c = get_coll_i18nname(c, ln)
         if len(c)>30:
             c_printable = c[:30] + "..."
         else:
@@ -450,9 +452,9 @@
 
     colls_nicely_ordered = []
     if cfg_nicely_ordered_collection_list:
-        colls_nicely_ordered = get_nicely_ordered_collection_list()
+        colls_nicely_ordered = get_nicely_ordered_collection_list(ln=ln)
     else:
-        colls_nicely_ordered = get_alphabetically_ordered_collection_list()
+        colls_nicely_ordered = get_alphabetically_ordered_collection_list(ln=ln)
 
     colls_nice = []
     for (cx, cx_printable) in colls_nicely_ordered:

Reply via email to