cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Merico Raffaele <raffaele.mer...@less.ch>
Subject AW: Setting the Locale during login
Date Tue, 07 Dec 2004 08:06:32 GMT
Hi Andrew

If you have your sitemap configured as follows:

--- sitemap snip ---
</map:components>
  <map:actions>	
    <map:action logger="sitemap.action.locale" name="locale"
src="org.apache.cocoon.acting.LocaleAction">
      <store-in-session>true</store-in-session>
      <create-session>true</create-session>
      <store-in-request>true</store-in-request>
      <store-in-cookie>false</store-in-cookie>
      <!--locale-attribute>locale</locale-attribute-->
      <!--language-attribute>language</language-attribute-->
      <!--country-attribute>country</country-attribute-->
      <!--variant-attribute>variant</variant-attribute-->
    </map:action>		
  </map:actions>		
</map:components>

<map:pipeline>
  <map:act type="locale">
    <map:match type="wildcard" pattern="....">
      ...
      <map:transform type="i18n">
        <map:parameter name="locale" value="{../locale}"/>
        <map:parameter name="untranslated-text" value="untranslated"/>
      </map:transform>
	...			
     </map:match>	
    </map:act>
</map:pipeline>
--- EOF sitemap snip ---

than for the determination of the current locale the following rules are
applied:
1) the request-parameter locale (ie locale=de_CH) is given and valid
2) the session-attribute locale is defined and valid
3) a cookie is found its parameter name is locale
4) the locale of the request-object is used (this corresponds usually to the
definition in the Web Browser)

When one rule is satisfied, the other one are ignored. Satisfied means: the
locale is defined and can be referenced with {../locale} in the sitemap).

So, using this approach a system can start working with the locale
definition in the web browser of the user. If the user wants to change the
locale he has to process a HTTP request (GET/POST) that contains also a
locale=%NEW_LOCALE% parameter. This value is than stored in its session. Any
further request will than be handled with this value stored in the session. 

Hope this helps ... Raffaele

Raffaele Merico
LESS Informatik AG
Böhnirainstrasse 14
CH-8800 Thalwil

> -----Urspr√ľngliche Nachricht-----
> Von: Andrew MacDonald [mailto:andrew_james_macdonald@yahoo.com]
> Gesendet: Montag, 6. Dezember 2004 18:10
> An: users@cocoon.apache.org
> Betreff: Setting the Locale during login
> 
> 
> Hello,
> We're trying to internationalize our portal and are
> having difficulty with the locale.  Currently, when
> the user logs in to the portal, the locale is passed
> as a request parameter (tacked onto the login form
> action).  However, we'd like to replace the request
> parameter locale with the user's locale preference (if
> they have one) which is loaded into the authentication
> context during login.  Currently we're doing this
> replacement in flow after the login process, but would
> like to have it performed during login (in the
> sitemap).  Any ideas on how this could be
> accomplished?
> 
> Thanks,
> Andrew MacDonald
> 
> 
> 		
> __________________________________ 
> Do you Yahoo!? 
> Yahoo! Mail - Easier than ever with enhanced search. Learn more.
> http://info.mail.yahoo.com/mail_250
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message