Title: Re: CFG_SITE_LANG and user's preferred languages set in browser

Hi,


> If the user-selected language is not preserved, then it is a bug.  We
> usually tend to preserve the language selection across links, but yes,
> it may happen that there are links not preserving them.  They should be
> fixed though.

> Can you cite a concrete link chain example that you are having a problem
> with on the demo site <http://invenio-demo.cern.ch/>?


Browsing the demo site in English, (with French as preferred language in the browser settings,
to highlight the problem):

http://invenio-demo.cern.ch/?ln=en


 - example 1: view the help:
 
   click on the 'Help' tab (http://invenio-demo.cern.ch/help/) <- 'ln' is missing
  
   Result: the page is displayed in French. The links on this page also do not have the 'ln' parameter
   and are also displayed in French.
  
  
- example 2: search results

  From the main page: http://invenio-demo.cern.ch/?ln=en
  
  perform a search on 'physics':
 
  http://invenio-demo.cern.ch/search?ln=en&sc=1&p=physics&f=&action_search=Search

  Result: the page is in English. In the results, the links 'Detailed record' and 'Similar records' do not have
  the ln parameter
  (eg. http://invenio-demo.cern.ch/record/6437, http://invenio-demo.cern.ch/search?p=recid%3A6437&rm=wrd).
 
  When clicking these links, the language of display is French.


When navigating in another language, eg. German or French, the problem does not occur: the 'ln' parameter is
preserved.


My observations: in several places of the code, the 'ln' parameter is explicitly removed if the current
language equals CFG_SITE_LANG, for example, in webstyle_templates.py, websearch_templates.py and webdoc.py.

Example from webstyle_templates.py:

     'langlink': ln != CFG_SITE_LANG and '?ln=' + ln or ''



In other cases, I think it may come from the url argument washing. In websearch_templates.tmpl_print_record_brief_links()

the links for 'Detailed record' and 'Similar records' are created. The function build_search_url is used, which
uses urlutils.drop_default_urlargd(), where all the parameters in the urls that have their default value
are removed. The default values for the search parameters are defined in 'search_results_default_urlargd'.
CFG_SITE_LANG is not defined in 'search_results_default_urlargd', but after a few tests it appeared that
drop_default_urlargd was still removing the 'ln' parameter if it was equal to CFG_SITE_LANG.

The problem comes from webinterface_handler.wash_urlargd(), which systematically adds 'ln':

    content['ln'] = (str, CFG_SITE_LANG)
   
This means that after calling websearch_webinterface.wash_search_urlargd(), which contains the following code:

    argd = wash_urlargd(form, search_results_default_urlargd)


search_results_default_urlargd does now contain 'ln': (str, CFG_SITE_LANG), which means that drop_default_urlargd()
will remove the 'ln' parameter from the url if it equals CFG_SITE_LANG, which results in links in html brief
without the 'ln' parameter for the default language.




Hope that I didn't ramble too much and that is it somewhat useful :)



Best regards,

Dominic Wyler

Reply via email to