[Using Sakai] anonymous visitor language

Daniel Merino daniel.merino at unavarra.es
Tue Oct 30 05:26:35 PDT 2012


Hi, Steve. Here it is: https://jira.sakaiproject.org/browse/SAK-22846

Thanks and best regards.

Steve Swinsburg escribió:
> Hi Daniel
>
> Could you raise a new Jira for the .anon bug? Send it my way. 
>
> Cheers
> Steve
>
> Sent from my iPhone
>
> On 30/10/2012, at 22:00, Daniel Merino <daniel.merino at unavarra.es> wrote:
>
>   
>> We haven't been able to deal with this. I searched in the code but it 
>> seems to me that this behaviour is inside kernel and is not trivial to 
>> change. I was not able to find it.
>>
>> When you enter a site with anonymous user, it always shows Tomcat's 
>> language. I have checked it in trunk and still happens there too.
>>
>> I have written a comment in official JIRA ( 
>> https://jira.sakaiproject.org/browse/SAK-10393 ), maybe some expert 
>> developer will be able to fix it.
>>
>> Best regards.
>>
>> Joao Carneiro escribió:
>>     
>>> Thank you all for your replies.
>>> Your final note however worries me. I intended to use this patch to 
>>> have a public site with a different language but you say it doesn't 
>>> work for .anon role.
>>> Is there a workaround for this or how do you deal with this?
>>> Chrs,
>>>
>>> Joao
>>>
>>>
>>> -----Mensagem Original----- From: Daniel Merino
>>> Sent: Tuesday, October 30, 2012 10:02 AM
>>> To: joao carneiro
>>> Cc: Miguel Carro Pellicer ; sakai-user at collab.sakaiproject.org
>>> Subject: Re: [Using Sakai] anonymous visitor language
>>>
>>> Hi, Joao. I have taken a look on our 2.7.1 patch that allows to select a
>>> site language.
>>>
>>> I think that Samoo's original patch works for 2.7.1 and is uploaded at
>>> https://jira.sakaiproject.org/browse/SAK-19449 . This patch has a little
>>> issue as default language is blank in the language list, but it works.
>>>
>>> After that, patch was applied in trunk at
>>> https://jira.sakaiproject.org/browse/SAK-10393 . I think that trunk was
>>> 2.8.x in that moment, but a comment in that JIRA says that it works with
>>> 2.7.1 too. I don't know if this is true.
>>>
>>> Finally, the issue with blank default language is addressed at
>>> https://jira.sakaiproject.org/browse/SAK-20756 . Again, I don't know if
>>> this works in 2.7.1 but is a very little patch, it should not be
>>> difficult to be applied handly.
>>>
>>> If you want our locally modified patch, I can send it to you, but I must
>>> warn you that our patch doesn't include changes in properties (as we
>>> manage them separately) and we have another tiny local change to display
>>> "euskera" (basque) instead of "vascuence" in language list, as is what
>>> our users demanded.
>>>
>>> Hope it helps.
>>> Best regards.
>>>
>>> PD: Another issue with this patch that we discovered a few weeks ago is
>>> that site's selected language doesn't work with .anon role.
>>>
>>> Miguel Carro Pellicer escribió:
>>>       
>>>> You're lucky!
>>>>
>>>> BTW, i think the community did some changes on this original patch, 
>>>> they added a default language option in the selector and maybe more 
>>>> changes.
>>>>
>>>> Can anyone give more information?
>>>>
>>>> Miguel.
>>>>
>>>>
>>>> El 29/10/2012 13:18, joao carneiro escribió:
>>>>         
>>>>> Thanks Miguel, that would be great.
>>>>>
>>>>> Chrs,
>>>>>
>>>>> Joao
>>>>>
>>>>> ------------------------------------------------------------------------ 
>>>>>
>>>>> Date: Mon, 29 Oct 2012 13:06:56 +0100
>>>>> From: farreri.sakai at gmail.com
>>>>> To: sakai-user at collab.sakaiproject.org
>>>>> Subject: Re: [Using Sakai] anonymous visitor language
>>>>>
>>>>> We contributed that feature. I think i have the patches for 2.7 and 
>>>>> 2.8, let me see our repo.
>>>>>
>>>>>
>>>>> El 29/10/2012 13:01, Steve Swinsburg escribió:
>>>>>
>>>>>    I believe this feature is in 2.9, perhaps trunk only. The
>>>>>    language of a site can be set differently to the default language
>>>>>    of the overall installation.
>>>>>    What version Sakai are you using?
>>>>>
>>>>>    Cheers
>>>>>    Steve
>>>>>
>>>>>    Sent from my iPhone
>>>>>
>>>>>    On 29/10/2012, at 22:44, "Joao Carneiro" <jcarneiro at netcabo.pt
>>>>>    <mailto:jcarneiro at netcabo.pt>> wrote:
>>>>>
>>>>>        Thanks Steve,
>>>>>         Wouldn’t it be possible to have different default languages
>>>>>        for different sites?
>>>>>         Chrs,
>>>>>         Joao
>>>>>         *From:* Steve Swinsburg <mailto:steve.swinsburg at gmail.com>
>>>>>        *Sent:* Monday, October 29, 2012 6:54 AM
>>>>>        *To:* Joao Carneiro <mailto:jcarneiro at netcabo.pt>
>>>>>        *Cc:* sakai-user at collab.sakaiproject.org
>>>>>        <mailto:sakai-user at collab.sakaiproject.org>
>>>>>        *Subject:* Re: [Using Sakai] anonymous visitor language
>>>>>         Hi Joao,
>>>>>         You can set the default language in your JAVA_OPTS. For
>>>>>        example for es_MX:
>>>>>         -Duser.language=es -Duser.region=MX
>>>>>         cheers,
>>>>>        Steve
>>>>>         On 29/10/2012, at 9:44 AM, Joao Carneiro
>>>>>        <jcarneiro at netcabo.pt <mailto:jcarneiro at netcabo.pt>> wrote:
>>>>>
>>>>>            Hi all,
>>>>>             Can anyone tell me how is the language for anonymous
>>>>>            users defined?
>>>>>            When an unauthenticated user visits a sakai public page
>>>>>            (where .anon can visit) how is the language selected and
>>>>>            how can I change it?
>>>>>            Thanks,
>>>>>             Joao
>>>>>            _______________________________________________
>>>>>            sakai-user mailing list
>>>>>            sakai-user at collab.sakaiproject.org
>>>>>            <mailto:sakai-user at collab.sakaiproject.org>
>>>>>            http://collab.sakaiproject.org/mailman/listinfo/sakai-user
>>>>>
>>>>>            TO UNSUBSCRIBE: send email to
>>>>>            sakai-user-unsubscribe at collab.sakaiproject.org
>>>>>            <mailto:sakai-user-unsubscribe at collab.sakaiproject.org>
>>>>>            with a subject of "unsubscribe"
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>    _______________________________________________
>>>>>    sakai-user mailing list
>>>>>    sakai-user at collab.sakaiproject.org 
>>>>> <mailto:sakai-user at collab.sakaiproject.org>
>>>>>    http://collab.sakaiproject.org/mailman/listinfo/sakai-user
>>>>>
>>>>>    TO UNSUBSCRIBE: send email to 
>>>>> sakai-user-unsubscribe at collab.sakaiproject.org 
>>>>> <mailto:sakai-user-unsubscribe at collab.sakaiproject.org> with a 
>>>>> subject of "unsubscribe"
>>>>>
>>>>>
>>>>> -- 
>>>>>
>>>>> cid:image001.jpg at 01C9F98A.71C74E60 <http://www.samoo.es/>
>>>>>
>>>>>  <http://www.samoo.es/>
>>>>>
>>>>> *Miguel Carro Pellicer*
>>>>>
>>>>> *Technical Manager - Director técnico*
>>>>>
>>>>> miguel.carro at samoo.es <mailto:miguel.carro at samoo.es>
>>>>>
>>>>> +34 - 673 80 32 69
>>>>>
>>>>> Skype: mcpellicer
>>>>>
>>>>> www.samoo.es <http://www.samoo.es>
>>>>>
>>>>>
>>>>> Este  correo  y  sus archivos asociados son privados y 
>>>>> confidenciales y va dirigido  exclusivamente  a su destinatario. Si 
>>>>> recibe este correo sin ser el  destinatario del mismo, le rogamos 
>>>>> proceda a su eliminación y lo ponga en  conocimiento del emisor. La 
>>>>> difusión por cualquier medio del contenido de  este  correo podría 
>>>>> ser sancionada conforme a lo previsto en las leyes españolas, Ley 
>>>>> Orgánica 15/1999 de Protección de Datos de Carácter Personal.  No  
>>>>> se autoriza la utilización con fines comerciales o para su 
>>>>> incorporación a ficheros automatizados de las direcciones del emisor 
>>>>> o del destinatario.”
>>>>>
>>>>>
>>>>> This mail and its attached files are confidential and are only and 
>>>>> exclusively intended to their addressee. In case you may receive 
>>>>> this mail not being its addressee, we beg you to let us know the 
>>>>> error by reply and to proceed to destroy it. The circulation by any 
>>>>> mean of this mail could be penalised in accordance with the Spanish 
>>>>> legislation. Is not allowed the use of both, the transmitter and the 
>>>>> addressee’s, address with a commercial aim, or in order to be 
>>>>> incorporated to automated data process or to any kind of files.
>>>>>
>>>>>
>>>>> P Antes de imprimir este correo electrónico piense bien si es 
>>>>> necesario hacerlo. El medioambiente es cosa de todos.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________ sakai-user mailing 
>>>>> list sakai-user at collab.sakaiproject.org 
>>>>> http://collab.sakaiproject.org/mailman/listinfo/sakai-user TO 
>>>>> UNSUBSCRIBE: send email to 
>>>>> sakai-user-unsubscribe at collab.sakaiproject.org with a subject of 
>>>>> "unsubscribe"
>>>>>           
>>>> -- 
>>>>
>>>> cid:image001.jpg at 01C9F98A.71C74E60 <http://www.samoo.es/>
>>>>
>>>>  <http://www.samoo.es/>
>>>>
>>>> *Miguel Carro Pellicer*
>>>>
>>>> *Technical Manager - Director técnico*
>>>>
>>>> miguel.carro at samoo.es <mailto:miguel.carro at samoo.es>
>>>>
>>>> +34 - 673 80 32 69
>>>>
>>>> Skype: mcpellicer
>>>>
>>>> www.samoo.es <http://www.samoo.es>
>>>>
>>>>
>>>> Este  correo  y  sus archivos asociados son privados y confidenciales 
>>>> y va dirigido  exclusivamente  a su destinatario. Si recibe este 
>>>> correo sin ser el  destinatario del mismo, le rogamos proceda a su 
>>>> eliminación y lo ponga en  conocimiento del emisor. La difusión por 
>>>> cualquier medio del contenido de  este  correo podría ser sancionada 
>>>> conforme a lo previsto en las leyes españolas, Ley Orgánica 15/1999 
>>>> de Protección de Datos de Carácter Personal.  No  se autoriza la 
>>>> utilización con fines comerciales o para su incorporación a ficheros 
>>>> automatizados de las direcciones del emisor o del destinatario.”
>>>>
>>>>
>>>> This mail and its attached files are confidential and are only and 
>>>> exclusively intended to their addressee. In case you may receive this 
>>>> mail not being its addressee, we beg you to let us know the error by 
>>>> reply and to proceed to destroy it. The circulation by any mean of 
>>>> this mail could be penalised in accordance with the Spanish 
>>>> legislation. Is not allowed the use of both, the transmitter and the 
>>>> addressee’s, address with a commercial aim, or in order to be 
>>>> incorporated to automated data process or to any kind of files.
>>>>
>>>>
>>>> P Antes de imprimir este correo electrónico piense bien si es 
>>>> necesario hacerlo. El medioambiente es cosa de todos.
>>>>
>>>>
>>>>
>>>> ------------------------------------------------------------------------
>>>>
>>>> Index: 
>>>> portal/portal-impl/impl/src/java/org/sakaiproject/portal/charon/handlers/SiteHandler.java 
>>>>
>>>> ===================================================================
>>>> ---  
>>>> portal/portal-impl/impl/src/java/org/sakaiproject/portal/charon/handlers/SiteHandler.java 
>>>> (revision 84074)
>>>> +++ 
>>>> portal/portal-impl/impl/src/java/org/sakaiproject/portal/charon/handlers/SiteHandler.java 
>>>> (working copy)
>>>> @@ -27,6 +27,7 @@
>>>> import java.util.List;
>>>> import java.util.Map;
>>>> import java.util.Set;
>>>> +import java.util.Locale;
>>>> import javax.servlet.http.HttpServletRequest;
>>>> import javax.servlet.http.HttpServletResponse;
>>>> @@ -38,6 +39,7 @@
>>>> import org.sakaiproject.authz.cover.SecurityService;
>>>> import org.sakaiproject.component.cover.ServerConfigurationService;
>>>> import org.sakaiproject.entity.api.ResourceProperties;
>>>> +import org.sakaiproject.entity.api.ResourcePropertiesEdit;
>>>> import org.sakaiproject.entity.cover.EntityManager;
>>>> import org.sakaiproject.exception.IdUnusedException;
>>>> import org.sakaiproject.exception.PermissionException;
>>>> @@ -57,6 +59,7 @@
>>>> import org.sakaiproject.user.cover.PreferencesService;
>>>> import org.sakaiproject.user.cover.UserDirectoryService;
>>>> import org.sakaiproject.util.Web;
>>>> +import org.sakaiproject.util.ResourceLoader;
>>>> /**
>>>>  * @author ieb
>>>> @@ -79,7 +82,8 @@
>>>> private int configuredTabsToDisplay = 5;
>>>> private boolean useDHTMLMore = false;
>>>> -
>>>> + + public SiteHandler()
>>>> {
>>>> setUrlFragment(SiteHandler.URL_FRAGMENT);
>>>> @@ -131,8 +135,8 @@
>>>> public void doSite(HttpServletRequest req, HttpServletResponse res, 
>>>> Session session,
>>>> String siteId, String pageId, String toolContextPath) throws 
>>>> ToolException,
>>>> IOException
>>>> - {
>>>> -
>>>> + { + boolean doFrameTop = 
>>>> "true".equals(req.getParameter("sakai.frame.top"));
>>>> boolean doFrameSuppress = 
>>>> "true".equals(req.getParameter("sakai.frame.suppress"));
>>>> @@ -201,7 +205,7 @@
>>>> }
>>>> return;
>>>> }
>>>> -
>>>> + // Lookup the page in the site - enforcing access control
>>>> // business rules
>>>> SitePage page = portal.getSiteHelper().lookupSitePage(pageId, site);
>>>> @@ -225,6 +229,10 @@
>>>> // should we consider a frameset ?
>>>> boolean doFrameSet = includeFrameset(rcontext, res, req, session, 
>>>> page);
>>>> + + + setSiteLanguage(site); + includeSiteNav(rcontext, req, session, 
>>>> siteId);
>>>> @@ -278,6 +286,8 @@
>>>> // This request is the destination of the request
>>>> portalService.setStoredState(null);
>>>> }
>>>> + + }
>>>> /**
>>>> @@ -405,6 +415,7 @@
>>>> {
>>>> skin = ServerConfigurationService.getString("skin.default");
>>>> }
>>>> + String skinRepo = ServerConfigurationService.getString("skin.repo");
>>>> rcontext.put("logoSkin", skin);
>>>> rcontext.put("logoSkinRepo", skinRepo);
>>>> @@ -731,5 +742,48 @@
>>>> }
>>>> return framesetRequested;
>>>> }
>>>> + + /**
>>>> + * *
>>>> + * + * @return Locale based on its string representation 
>>>> (language_region)
>>>> + */
>>>> + private Locale getLocaleFromString(String localeString)
>>>> + {
>>>> + String[] locValues = localeString.trim().split("_");
>>>> + if (locValues.length >= 3)
>>>> + return new Locale(locValues[0], locValues[1], locValues[2]); // 
>>>> language, country, variant
>>>> + else if (locValues.length == 2)
>>>> + return new Locale(locValues[0], locValues[1]); // language, country
>>>> + else if (locValues.length == 1)
>>>> + return new Locale(locValues[0]); // language
>>>> + else
>>>> + return Locale.getDefault();
>>>> + }
>>>> + + + void setSiteLanguage(Site site)
>>>> + {
>>>> + ResourceLoader rl = new ResourceLoader();
>>>> + + ResourcePropertiesEdit props = site.getPropertiesEdit();
>>>> + + String locale_string = props.getProperty("locale_string");
>>>> + + Locale loc;
>>>> + + // if no language was specified when creating the site, set 
>>>> default language to session
>>>> + if(locale_string == null || locale_string == "")
>>>> + { + loc = rl.setContextLocale(null);
>>>> + }
>>>> + + // if you have indicated a language when creating the site, set 
>>>> selected language to session
>>>> + else
>>>> + { + Locale locale = getLocaleFromString(locale_string); + loc = 
>>>> rl.setContextLocale(locale); + }
>>>> + }
>>>> }
>>>> Index: 
>>>> site-manage/site-manage-tool/tool/src/bundle/sitesetupgeneric.properties
>>>> ===================================================================
>>>> ---  
>>>> site-manage/site-manage-tool/tool/src/bundle/sitesetupgeneric.properties 
>>>> (revision 84077)
>>>> +++ 
>>>> site-manage/site-manage-tool/tool/src/bundle/sitesetupgeneric.properties 
>>>> (working copy)
>>>> @@ -436,6 +436,8 @@
>>>> newsc.reqsite = Request Site
>>>> newsc.crsite = Create Site
>>>> +newsc.language.none = No Language provided
>>>> +
>>>> #NewSiteCourse
>>>> nscourse.creating = Course/Section Information
>>>> ### (moot) nscourse.step = Step 1 of
>>>> @@ -541,6 +543,9 @@
>>>> sinfo.means = means required information.
>>>> sinfo.stitle = Site Title
>>>> sinfo.url_alias = Site URL Alias
>>>> +
>>>> +sinfo.language = Site Language
>>>> +
>>>> sinfo.descr = Description
>>>> sinfo.display = (displayed on the site's homepage)
>>>> sinfo.short = Short Description
>>>> @@ -582,6 +587,8 @@
>>>> sitediconf.siticonema = Site Contact Email
>>>> sitediconf.sittit     = Site Title
>>>> +sitediconf.language = Site Language
>>>> +
>>>> sitediinf.alert     = Alert:
>>>> sitediinf.app       = Appearance (Icon)
>>>> ### (moot) sitediinf.app.none  = *default*
>>>> Index: 
>>>> site-manage/site-manage-tool/tool/src/java/org/sakaiproject/site/tool/LocaleComparator.java 
>>>>
>>>> ===================================================================
>>>> ---  
>>>> site-manage/site-manage-tool/tool/src/java/org/sakaiproject/site/tool/LocaleComparator.java 
>>>> (revision 0)
>>>> +++ 
>>>> site-manage/site-manage-tool/tool/src/java/org/sakaiproject/site/tool/LocaleComparator.java 
>>>> (revision 0)
>>>> @@ -0,0 +1,73 @@
>>>> +/********************************************************************************** 
>>>>
>>>> + * $URL: 
>>>> https://source.sakaiproject.org/svn/trunk/sakai/admin-tools/su/src/java/org/sakaiproject/tool/su/SuTool.java 
>>>> $
>>>> + * $Id: SuTool.java 6970 2006-03-23 23:25:04Z zach.thomas at txstate.edu $
>>>> + 
>>>> *********************************************************************************** 
>>>>
>>>> + *
>>>> + * Copyright (c) 2005, 2006, 2008 The Sakai Foundation
>>>> + *
>>>> + * Licensed under the Educational Community License, Version 2.0 
>>>> (the "License");
>>>> + * you may not use this file except in compliance with the License.
>>>> + * You may obtain a copy of the License at
>>>> + *
>>>> + *       http://www.osedu.org/licenses/ECL-2.0
>>>> + *
>>>> + * Unless required by applicable law or agreed to in writing, software
>>>> + * distributed under the License is distributed on an "AS IS" BASIS,
>>>> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
>>>> implied.
>>>> + * See the License for the specific language governing permissions and
>>>> + * limitations under the License.
>>>> + *
>>>> + 
>>>> **********************************************************************************/ 
>>>>
>>>> +
>>>> +package org.sakaiproject.site.tool;
>>>> +
>>>> +import java.util.Comparator;
>>>> +import java.util.Locale;
>>>> +
>>>> +/**
>>>> + * Comparator for sorting locale by DisplayName
>>>> + */
>>>> +public final class LocaleComparator implements Comparator
>>>> +{
>>>> + /**
>>>> + * * Compares Locale objects by comparing the DisplayName * *
>>>> + * + * @param obj1
>>>> + *        1st Locale Object for comparison *
>>>> + * @param obj2
>>>> + *        2nd Locale Object for comparison *
>>>> + * @return negative, zero, or positive integer * (obj1 charge is 
>>>> less than, equal to, or greater than the obj2 charge)
>>>> + */
>>>> + public int compare(Object obj1, Object obj2)
>>>> + {
>>>> + if (obj1 instanceof Locale && obj2 instanceof Locale)
>>>> + {
>>>> + Locale localeOne = (Locale) obj1;
>>>> + Locale localeTwo = (Locale) obj2;
>>>> +
>>>> + String displayNameOne = localeOne.getDisplayName();
>>>> + String displayNameTwo = localeTwo.getDisplayName();
>>>> +
>>>> + return displayNameOne.compareTo(displayNameTwo);
>>>> + }
>>>> + else
>>>> + {
>>>> + throw new ClassCastException("Inappropriate object class for 
>>>> LocaleComparator");
>>>> + }
>>>> + }
>>>> +
>>>> + /**
>>>> + * * Override of equals method * *
>>>> + * + * @param obj
>>>> + *        LocaleComparator object *
>>>> + * @return true if equal, false if not equal
>>>> + */
>>>> + public boolean equals(Object obj)
>>>> + {
>>>> + if (obj instanceof LocaleComparator)
>>>> + return super.equals(obj);
>>>> + else
>>>> + return false;
>>>> + }
>>>> +}
>>>> Index: 
>>>> site-manage/site-manage-tool/tool/src/java/org/sakaiproject/site/tool/SiteAction.java 
>>>>
>>>> ===================================================================
>>>> ---  
>>>> site-manage/site-manage-tool/tool/src/java/org/sakaiproject/site/tool/SiteAction.java 
>>>> (revision 84077)
>>>> +++ 
>>>> site-manage/site-manage-tool/tool/src/java/org/sakaiproject/site/tool/SiteAction.java 
>>>> (working copy)
>>>> @@ -156,6 +156,7 @@
>>>> import org.sakaiproject.util.Validator;
>>>> import org.sakaiproject.util.Web;
>>>> +
>>>> /**
>>>>  * <p>
>>>>  * SiteAction controls the interface for worksite setup.
>>>> @@ -299,6 +300,9 @@
>>>> private final static String PROP_SITE_TERM_EID = "term_eid";
>>>> + + private final static String PROP_SITE_LANGUAGE = "locale_string";
>>>> + /**
>>>> * Name of the state attribute holding the site list column list is 
>>>> sorted
>>>> * by
>>>> @@ -659,6 +663,12 @@
>>>> /** the course set definition from CourseManagementService **/
>>>> private final static String STATE_COURSE_SET = "state_course_set";
>>>> + + private List prefLocales = new ArrayList();
>>>> + private String SAKAI_LOCALES = "locales";
>>>> + private String SAKAI_LOCALES_MORE = "locales.more";
>>>> + private LocaleComparator localeComparator = new LocaleComparator(); 
>>>> + /**
>>>> * what are the tool ids within Home page?
>>>> * If this is for a newly added Home tool, get the tool ids from 
>>>> template site or system set default
>>>> @@ -1629,6 +1639,19 @@
>>>> context.put("short_description", siteInfo.short_description);
>>>> context.put("siteContactName", siteInfo.site_contact_name);
>>>> context.put("siteContactEmail", siteInfo.site_contact_email);
>>>> + + /// site language information
>>>> + + String locale_string_selected = (String) 
>>>> state.getAttribute("locale_string");
>>>> + if(locale_string_selected == ""  || locale_string_selected == null) 
>>>> + context.put("locale_string_selected", ""); + else
>>>> + {
>>>> + Locale locale_selected = getLocaleFromString(locale_string_selected);
>>>> + context.put("locale_string_selected", locale_selected);
>>>> + }
>>>> + + siteType = (String) state.getAttribute(STATE_SITE_TYPE);
>>>> toolRegistrationSelectedList = (List) state
>>>> .getAttribute(STATE_TOOL_REGISTRATION_SELECTED_LIST);
>>>> @@ -2016,6 +2039,11 @@
>>>> // revising a existing site's tool
>>>> context.put("existingSite", Boolean.TRUE);
>>>> context.put("continue", "14");
>>>> + + ResourcePropertiesEdit props = site.getPropertiesEdit();
>>>> + + String locale_string = props.getProperty(PROP_SITE_LANGUAGE);
>>>> + context.put("locale_string",locale_string);
>>>> } else {
>>>> // new site
>>>> context.put("existingSite", Boolean.FALSE);
>>>> @@ -2144,6 +2172,15 @@
>>>> context.put("form_site_contact_name", siteInfo.site_contact_name);
>>>> context.put("form_site_contact_email", siteInfo.site_contact_email);
>>>> + // available languages in sakai.properties
>>>> + List locales = getPrefLocales();
>>>> + + // insert blank item in the first position to give the option not 
>>>> to select any language + if(locales.get(0) != "")
>>>> + locales.add(0,"");
>>>> + + context.put("locales",locales); + return (String) 
>>>> getContext(data).get("template") + TEMPLATE[13];
>>>> case 14:
>>>> /*
>>>> @@ -2163,7 +2200,29 @@
>>>> }
>>>> context.put("oTitle", site.getTitle());
>>>> context.put("title", siteInfo.title);
>>>> -
>>>> + + // get updated language
>>>> + String new_locale_string = (String) 
>>>> state.getAttribute("locale_string"); + if(new_locale_string == ""  || 
>>>> new_locale_string == null) + context.put("new_locale", ""); + else
>>>> + {
>>>> + Locale new_locale = getLocaleFromString(new_locale_string);
>>>> + context.put("new_locale", new_locale);
>>>> + }
>>>> + + // get site language saved
>>>> + ResourcePropertiesEdit props = site.getPropertiesEdit(); + String 
>>>> oLocale_string = props.getProperty(PROP_SITE_LANGUAGE); + 
>>>> if(oLocale_string == "" || oLocale_string == null) + 
>>>> context.put("oLocale", ""); + else
>>>> + {
>>>> + Locale oLocale = getLocaleFromString(oLocale_string);
>>>> + context.put("oLocale", oLocale);
>>>> + }
>>>> + + context.put("description", siteInfo.description);
>>>> context.put("oDescription", site.getDescription());
>>>> context.put("short_description", siteInfo.short_description);
>>>> @@ -5432,6 +5491,7 @@
>>>> EmailService.send(from, to, message_subject, content,
>>>> headerTo, replyTo, null);
>>>> // revert back the local setting to default
>>>> + rb.setContextLocale(Locale.getDefault());
>>>> }
>>>> catch (Exception e)
>>>> @@ -5444,7 +5504,7 @@
>>>> // To Support
>>>> from = cUser.getEmail();
>>>> - // set locale to system default
>>>> + // set locale to system default 
>>>> rb.setContextLocale(Locale.getDefault());
>>>> to = requestEmail;
>>>> headerTo = requestEmail;
>>>> @@ -5518,7 +5578,7 @@
>>>> // To the Instructor
>>>> from = requestEmail;
>>>> to = cUser.getEmail();
>>>> - // set the locale to individual receipient's setting
>>>> + // set the locale to individual receipient's setting 
>>>> rb.setContextLocale(rb.getLocale(cUser.getId()));
>>>> headerTo = to;
>>>> replyTo = to;
>>>> @@ -5531,13 +5591,13 @@
>>>> content = buf.toString();
>>>> EmailService.send(from, to, message_subject, content, headerTo,
>>>> replyTo, null);
>>>> - // revert the locale to system default
>>>> + // revert the locale to system default 
>>>> rb.setContextLocale(Locale.getDefault());
>>>> state.setAttribute(REQUEST_SENT, Boolean.valueOf(true));
>>>> } // if
>>>> - // reset locale to user default
>>>> + // reset locale to user default rb.setContextLocale(null);
>>>> } // sendSiteRequest
>>>> @@ -5607,7 +5667,7 @@
>>>> }
>>>> // To Support
>>>> - //set local to default
>>>> + //set local to default rb.setContextLocale(Locale.getDefault());
>>>> from = UserDirectoryService.getCurrentUser().getEmail();
>>>> to = requestEmail;
>>>> @@ -5643,6 +5703,7 @@
>>>> } // if
>>>> // reset locale to user default
>>>> + rb.setContextLocale(null);
>>>> } // sendSiteNotification
>>>> @@ -6310,7 +6371,14 @@
>>>> if (contactEmail != null) {
>>>> siteProperties.addProperty(PROP_SITE_CONTACT_EMAIL, contactEmail);
>>>> }
>>>> -
>>>> + + /// site language information
>>>> + + String locale_string = (String) 
>>>> state.getAttribute("locale_string"); + + 
>>>> siteProperties.removeProperty(PROP_SITE_LANGUAGE); + 
>>>> siteProperties.addProperty(PROP_SITE_LANGUAGE, locale_string);
>>>> + if (state.getAttribute(STATE_MESSAGE) == null) {
>>>> try {
>>>> SiteService.save(Site);
>>>> @@ -6722,9 +6790,10 @@
>>>> ParameterParser params = data.getParameters();
>>>> String publishUnpublish = params.getString("publishunpublish");
>>>> String include = params.getString("include");
>>>> -
>>>> + if (sEdit != null) {
>>>> // editing existing site
>>>> + // publish site or not
>>>> if (publishUnpublish != null
>>>> && publishUnpublish.equalsIgnoreCase("publish")) {
>>>> @@ -6772,10 +6841,11 @@
>>>> }
>>>> } else {
>>>> // adding new site
>>>> + if (state.getAttribute(STATE_SITE_INFO) != null) {
>>>> SiteInfo siteInfo = (SiteInfo) state
>>>> .getAttribute(STATE_SITE_INFO);
>>>> -
>>>> + if (publishUnpublish != null
>>>> && publishUnpublish.equalsIgnoreCase("publish")) {
>>>> siteInfo.published = true;
>>>> @@ -6828,6 +6898,7 @@
>>>> state.setAttribute(STATE_TEMPLATE_INDEX, "10");
>>>> }
>>>> }
>>>> + } // doUpdate_site_access
>>>> @@ -8073,6 +8144,7 @@
>>>> addAlert(state, rb.getString("site_group_title_length_limit_1") + 
>>>> SiteConstants.SITE_GROUP_TITLE_LIMIT + " " + 
>>>> rb.getString("site_group_title_length_limit_2")); }
>>>>         }
>>>> + if (params.getString("description") != null) {
>>>> StringBuilder alertMsg = new StringBuilder();
>>>> String description = params.getString("description");
>>>> @@ -9066,6 +9138,13 @@
>>>> }
>>>> ResourcePropertiesEdit rp = site.getPropertiesEdit();
>>>> + + /// site language information
>>>> + + String locale_string = (String) 
>>>> state.getAttribute("locale_string"); + + 
>>>> rp.addProperty(PROP_SITE_LANGUAGE, locale_string);
>>>> + site.setShortDescription(siteInfo.short_description);
>>>> site.setPubView(siteInfo.include);
>>>> site.setJoinable(siteInfo.joinable);
>>>> @@ -10157,6 +10236,7 @@
>>>> public String site_contact_email = NULL_STRING; // site contact email
>>>> public String term = NULL_STRING; // academic term
>>>> + public String getSiteId() {
>>>> return site_id;
>>>> @@ -10224,7 +10304,7 @@
>>>> public void setTerm(String term) {
>>>> this.term = term;
>>>> - }
>>>> + } } // SiteInfo
>>>> @@ -11841,7 +11921,11 @@
>>>> SessionState state = ((JetspeedRunData) 
>>>> data).getPortletSessionState(((JetspeedRunData) data).getJs_peid());
>>>> ParameterParser params = data.getParameters();
>>>> -
>>>> + + String locale_string = params.getString("locales"); + + 
>>>> state.setAttribute("locale_string",locale_string);
>>>> + String option = params.getString("option");
>>>> if ("removeSection".equals(option))
>>>> {
>>>> @@ -11859,6 +11943,70 @@
>>>> doCancel(data);
>>>> }
>>>> }
>>>> + + /**
>>>> + * *
>>>> + * + * @return Locale based on its string representation 
>>>> (language_region)
>>>> + */
>>>> + private Locale getLocaleFromString(String localeString)
>>>> + {
>>>> + String[] locValues = localeString.trim().split("_");
>>>> + if (locValues.length >= 3)
>>>> + return new Locale(locValues[0], locValues[1], locValues[2]); // 
>>>> language, country, variant
>>>> + else if (locValues.length == 2)
>>>> + return new Locale(locValues[0], locValues[1]); // language, country
>>>> + else if (locValues.length == 1)
>>>> + return new Locale(locValues[0]); // language
>>>> + else
>>>> + return Locale.getDefault();
>>>> + }
>>>> + /**
>>>> + * @return Returns the prefLocales
>>>> + */
>>>> + + public List getPrefLocales()
>>>> + {
>>>> + // Initialize list of supported locales, if necessary
>>>> + if (prefLocales.size() == 0)
>>>> + {
>>>> + Locale[] localeArray = null;
>>>> + String localeString = 
>>>> ServerConfigurationService.getString(SAKAI_LOCALES);
>>>> + String localeStringMore = 
>>>> ServerConfigurationService.getString(SAKAI_LOCALES_MORE);
>>>> + + if ( localeString == null )
>>>> + localeString = "";
>>>> + if ( localeStringMore != null && !localeStringMore.equals("") )
>>>> + localeString += ","+localeStringMore;
>>>> +
>>>> + if ( !localeString.equals("") )
>>>> + {
>>>> + String[] sakai_locales = localeString.split(",");
>>>> + localeArray = new Locale[sakai_locales.length + 1];
>>>> + for (int i = 0; i < sakai_locales.length; i++)
>>>> + localeArray[i] = getLocaleFromString(sakai_locales[i]);
>>>> + localeArray[localeArray.length - 1] = Locale.getDefault();
>>>> + }
>>>> + else
>>>> + // if no locales specified, get default list
>>>> + {
>>>> + localeArray = new Locale[] { Locale.getDefault() };
>>>> + }
>>>> +
>>>> + // Sort locales and add to prefLocales (removing duplicates)
>>>> + Arrays.sort(localeArray, localeComparator);
>>>> + for (int i = 0; i < localeArray.length; i++)
>>>> + {
>>>> + if (i == 0 || !localeArray[i].equals(localeArray[i - 1]))
>>>> + { + prefLocales.add(localeArray[i]);
>>>> + }
>>>> + }
>>>> + }
>>>> +
>>>> + return prefLocales;
>>>> + }
>>>> + }
>>>> Index: 
>>>> site-manage/site-manage-tool/tool/src/webapp/vm/sitesetup/chef_site-newSiteConfirm.vm 
>>>>
>>>> ===================================================================
>>>> ---  
>>>> site-manage/site-manage-tool/tool/src/webapp/vm/sitesetup/chef_site-newSiteConfirm.vm 
>>>> (revision 84077)
>>>> +++ 
>>>> site-manage/site-manage-tool/tool/src/webapp/vm/sitesetup/chef_site-newSiteConfirm.vm 
>>>> (working copy)
>>>> @@ -217,7 +217,23 @@
>>>>  </td>
>>>>  </tr>
>>>>  <tr>
>>>> + + <tr>
>>>> + <th>
>>>> + $tlang.getString("sitediconf.language")
>>>> + </th>
>>>> + <td> + #if ($locale_string_selected == "")
>>>> + <span 
>>>> class="instruction">$tlang.getString("newsc.language.none")</span>
>>>> + #else
>>>> + $validator.escapeHtml($locale_string_selected.getDisplayName())
>>>> + #end + </td>
>>>> + </tr>
>>>> + + + <tr>
>>>> <th colspan="2">
>>>> <h4>
>>>> $tlang.getString("newsc.descr")
>>>> Index: 
>>>> site-manage/site-manage-tool/tool/src/webapp/vm/sitesetup/chef_site-siteInfo-editInfo.vm 
>>>>
>>>> ===================================================================
>>>> ---  
>>>> site-manage/site-manage-tool/tool/src/webapp/vm/sitesetup/chef_site-siteInfo-editInfo.vm 
>>>> (revision 84077)
>>>> +++ 
>>>> site-manage/site-manage-tool/tool/src/webapp/vm/sitesetup/chef_site-siteInfo-editInfo.vm 
>>>> (working copy)
>>>> @@ -184,6 +184,18 @@
>>>> $!selectedTerm
>>>> </p> #end
>>>> +
>>>> + <div class="shorttext">
>>>> + <label for="language">
>>>> + $tlang.getString("sinfo.language")
>>>> + </label> + <select name="locales" class="indnt2" id="locales" 
>>>> size="5"> + #foreach($locale in $locales) + <option 
>>>> value="$locale.toString()" #if ($locale.toString() == 
>>>> $locale_string)selected="true" #elseif($locale.toString() == 
>>>> "")selected="true" 
>>>> #end>$validator.escapeHtml($locale.getDisplayName())</option> + #end 
>>>> + </select>
>>>> + </div>
>>>> + <div class="longtext">
>>>> <label for="description" class="block">
>>>> $tlang.getString("sitediinf.des")
>>>> Index: 
>>>> site-manage/site-manage-tool/tool/src/webapp/vm/sitesetup/chef_site-siteInfo-editInfoConfirm.vm 
>>>>
>>>> ===================================================================
>>>> ---  
>>>> site-manage/site-manage-tool/tool/src/webapp/vm/sitesetup/chef_site-siteInfo-editInfoConfirm.vm 
>>>> (revision 84077)
>>>> +++ 
>>>> site-manage/site-manage-tool/tool/src/webapp/vm/sitesetup/chef_site-siteInfo-editInfoConfirm.vm 
>>>> (working copy)
>>>> @@ -42,6 +42,28 @@
>>>> </td> </tr>
>>>> #end
>>>> + + <tr>
>>>> + <th>
>>>> + $tlang.getString("sitediconf.language")
>>>> + </th>
>>>> + <td> + #if (!$new_locale.equals("") && !$oLocale.equals(""))
>>>> + #if (!$new_locale.toString().equals($oLocale.toString()))
>>>> + <span 
>>>> class="highlight">$validator.escapeHtml($new_locale.getDisplayName())</span> 
>>>>
>>>> + #else
>>>> + $validator.escapeHtml($new_locale.getDisplayName())
>>>> + #end
>>>> + #elseif (!$new_locale.equals(""))
>>>> + <span 
>>>> class="highlight">$validator.escapeHtml($new_locale.getDisplayName())</span> 
>>>>
>>>> + #elseif ($oLocale.equals(""))
>>>> + <span 
>>>> class="instruction">$tlang.getString("newsc.language.none")</span>
>>>> + #else
>>>> + <span class="highlight">$tlang.getString("newsc.language.none")</span>
>>>> + #end
>>>> + </td>
>>>> + </tr>
>>>> + #if($!description)
>>>> <tr>
>>>> <th>
>>>>
>>>> ------------------------------------------------------------------------
>>>>
>>>> _______________________________________________
>>>> sakai-user mailing list
>>>> sakai-user at collab.sakaiproject.org
>>>> http://collab.sakaiproject.org/mailman/listinfo/sakai-user
>>>>
>>>> TO UNSUBSCRIBE: send email to 
>>>> sakai-user-unsubscribe at collab.sakaiproject.org with a subject of 
>>>> "unsubscribe"
>>>>         
>> -- 
>> Daniel Merino Echeverría
>> daniel.merino at unavarra.es
>> Gestor de teleformación - Centro Superior de Innovación Educativa.
>> Tfno: 948-168489 - Universidad Pública de Navarra.
>> --
>> Los amigos van y vienen, pero los enemigos se acumulan.
>> _______________________________________________
>> sakai-user mailing list
>> sakai-user at collab.sakaiproject.org
>> http://collab.sakaiproject.org/mailman/listinfo/sakai-user
>>
>> TO UNSUBSCRIBE: send email to sakai-user-unsubscribe at collab.sakaiproject.org with a subject of "unsubscribe"
>>     
>
>   

-- 
Daniel Merino Echeverría
daniel.merino at unavarra.es
Gestor de teleformación - Centro Superior de Innovación Educativa.
Tfno: 948-168489 - Universidad Pública de Navarra.
--
En teoría, no existe diferencia entre teoría y práctica; en la práctica 
sí la hay.


More information about the sakai-user mailing list