Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Anders Haahr 26 posts 31 karma points
    May 23, 2011 @ 10:21
    Anders Haahr
    0

    Another URL rewrite question (or rather a sanity check :-P)

    Hi,

    I have made an umbraco based website with two languages (Danish and English). In my case Danish is the primary, "default" language. I am using the "tab strategy" where fields are created in multiple versions, one for each language (like "myfield", "myfield_en" etc).

    It works, and initially I am using a querystring parm to change language (?lang=en).

    I would like to use URL rewriting to get rid of the query parm (www.mydomain.com/en/somepage.aspx instead of www.mydomain.com/somepage.aspx?lang=en). I have declared urlrewrite rules for this, and they work too :)

    Now, my problem is this:

    Umbraco seems to do all rendering of XSLTs and <umbraco:item /> before the OnInit in the good old asp.net page lifecycle. I was surprised by this, because I expected to be able to actually use the webcontrols' lifecycle hooks (like OnLoad, OnPreRender etc).

    This means I can't detect some state in OnInit or OnLoad, set some session variable and use this state for rendering, but I think there must be some good reason for it (I hope there is ;)). In my case I would determine language by checking the URL, save the determined language in session and use it for rendering the site's links. This can not be done straight forward since hooking OnInit on my top level master page is too late.

    So my plan is now to cover my loose ends by:

    - create a class that inherits umbraco.Global, override Application_BeginRequest and determine language from the request's URL in this method.
    - create my own xslt extension and write an extended version of umbraco.library.NiceUrl in order to easily get nice localized urls (with culture in the start of the path (like /en-US/))
    - and maybe not very crucial I will use CurrentThread.CurrentUICulture for setting the UI culture rather than using some pathetic session variable, and then make a GetCurrentUICulture method in my xslt extension.

    I think it is a nice, quick and easy solution, but since I have an extremely hard time finding any structured documentation for Umbraco, I would like to know, if Umbraco has some built in feature for this kind of "URL localization". I think not, but I don't know Umbraco very well.

    Oh, and can anyone point me to some documentation for the web editor clients translation feature. I would like to know what it is about :)

    Thanks in advance.

     

     

     

     

  • Stefan Kip 1614 posts 4131 karma points c-trib
    May 23, 2011 @ 11:30
Please Sign in or register to post replies

Write your reply to:

Draft