Forum OpenACS Development: Re: xowiki 0.39

Collapse
5: Re: xowiki 0.39 (response to 2)
Posted by Gustaf Neumann on
Malte,

i tried your setup on my machine, but i can't reproduce what you are reporting. The code works just fine. Let us assume

  • package parameter index_page: index (or empty, "index" is the default)
  • package parameter use_connection_locale: 1
  • browser setting: language de
  • server setting (system locale): en
  • xowiki mounted as: xowiki
  • You have a page named de:index and a page named en:index
if you browse to http://.../xowiki/, you get the german page (de:index). If you set your browser-setting to russian, you get en:index, the same happens if you set the browser setting to english....

What's different on your site?

Collapse
9: Re: xowiki 0.39 (response to 5)
Posted by Malte Sussdorff on
Somehow my setup seems to be screwed up, but I don't know how:
  • package parameter index_page: empty
  • package parameter use_connection_locale: 1
  • browser setting: language de_DE
  • server setting (system locale): de_DE
  • xowiki mounted as: xowiki
  • package_prefix: /
  • You have a page named de:index and a page named en:index
  • I have a page de:company but I do NOT have a page en:company

This is my /web/cognovis/www/index.vuh:

# -*- tcl -*-
::xowiki::Package initialize -ad_doc {

This is the resolver for this package. It turns a request into
an object and executes the object with the computed method

@author Gustaf Neumann (mailto:gustaf.neumann@wu-wien.ac.at)
@creation-date July, 2006
@cvs-id $Id: index.vuh,v 1.5 2006/09/15 16:45:00 gustafn Exp $

} -parameter {
{-m view}
{-folder_id:integer 0}
} -url /xowiki[ns_conn url]

::$package_id log "--starting... [ns_conn url] [ns_conn query] \
form vars = [ns_set array [ns_getform]]"
#::$package_id exists_form_parameter creator
#::$package_id log "-- [::xo::cc serialize]"

::$package_id reply_to_user [::$package_id invoke -method $m]

::$package_id log "--i ::$package_id DONE"
ad_script_abort

Now I browse:

What confuses me now is the fact that it does not default back to de_DE, which is the system wide locale as set in /acs-lang/admin. I managed to fix the fallback by adding the following code to Package instproc resolve_request {-path} { (right after the last if {$item_id == 0} statement where you try the normalized name:

if {$item_id == 0} {
set nname [my normalize_name $name]
set item_id [::Generic::CrItem lookup -name $nname -parent_id $folder_id]
my log "--try $nname -> $item_id"
}

######## New code begins here ############

util_user_message -message "Content is not available in your locale"

# Item is still empty, try default language for the package
if {$item_id == 0} {
set system_locale [lang::system::locale]
set lang [string range $system_locale 0 1]
set name ${lang}:$local_name
set item_id [::Generic::CrItem lookup -name $name -parent_id $folder_id]
}

# Item is still empty, try default language for the site
if {$item_id == 0} {
set system_locale [lang::system::locale -site_wide]
set lang [string range $system_locale 0 1]
set name ${lang}:$local_name
set item_id [::Generic::CrItem lookup -name $name -parent_id $folder_id]
}

###### New code ends here ########

This results in the (desired) behaviour, that if the content is available in site locale, the site locale is presented, yet the navigation (categories portlet) still only shows the pages which are available in this language. Additionally the user notification shows up.

Maybe this should be made a switch (DefaultToSiteLocaleP) but I won't commit anything anyway until Gustaf could take a look.

Still, the index page is a mistery to me....

Collapse
10: Re: xowiki 0.39 (response to 9)
Posted by Malte Sussdorff on
The util_user_message needs to go within the if statement, not right before (otherwise it shows up all the time, which does not make sense). I modified it a bit to allow automatic creation of new pages:

          # Item is still empty, try default language for the package
          if {$item_id == 0} {
              set new_url [export_vars -base "/xowiki/" -url {{edit-new 1} {return_url [ad_return_url]} {object_type "xowiki::Page"} {na\me $name}}]
              util_user_message -message "Content is not available in your locale. Create <a href=\"$new_url\" target=new()>new</a>" -ht\ml
              set system_locale [lang::system::locale]
              set lang [string range $system_locale 0 1]
              set name ${lang}:$local_name
              set item_id [::Generic::CrItem lookup -name $name -parent_id $folder_id]
          }

What I found interesting though is that if I unpublish the item in question (e.g. en:company), the page is still showing up the en:company page, instead of (as I would have assumed) the de:company page with the user notification. If I delete the page in question all is fine.

My assumption is that ::Generic::CrItem lookup -name $name -parent $folder_Id does not query for published items and could use a "-live" flag to query only items which are live. But I won't dive down into these waters :).

Collapse
11: Re: xowiki 0.39 (response to 10)
Posted by Gustaf Neumann on
malte, before i look into the details: can it be, that a setting in the folder_object like

set index_page "en:index"

causes the confusion?

-gustaf

Collapse
12: Re: xowiki 0.39 (response to 11)
Posted by Malte Sussdorff on
Yeah. You were absolutely right. That was it. Now I know: First check the folder object than check the parameters... Maybe we could have a warning on the parameters page like "YOU HAVE TO CHECK THE FOLDER OBJECT HERE" 😊.

I could not figure out in the documentation if you can say in an xowiki page directly which folder object to use, so you could have different settings depending on page. I solved this so far by just mounting a different xowiki instance (http://www.cognovis.de/developer) which is only available in English and therefore has different settings in the folder object for language etc.. Did I do this unnecessarily ?