Copied to clipboard

Flag this post as spam?

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


  • Lewis 7 posts 27 karma points
    Apr 09, 2010 @ 15:46
    Lewis
    0

    Creating a Culture-dependant article list in XLST

    Hi there!

    I'm developing a page that content editors can add news articles to. The editor selects a language for each article and once saved and published, appears in the list. The list XSLT cycles through the articles and displays only the articles that match the browsers' language.

    I'm currently using query strings to achieve this, but need to automate the culture detection.

    Im trying to achieve this by extending the XSLT with javascript. The problem is that when referencing the "navigator" object, the XSLT throws an exception ("Variable 'navigator' is not declared").

    Could anybody suggest a better method in obtaining the client browser culture for an XLST logical operation or offer any help for the error I'm getting with javascript?

    Thanks

    Lewis

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Apr 09, 2010 @ 17:39
    Thomas Höhler
    0

    You can create your own XsltExtension like this:

    public static string GetUserLanguage()
    {
    return System.Web.HttpContext.Current.Request.UserLanguages.Length > 0
    ? System.Web.HttpContext.Current.Request.UserLanguages[0]
    : "";
    }

    hth, Thomas

  • Lewis 7 posts 27 karma points
    Apr 12, 2010 @ 16:30
    Lewis
    0

    Yes, Thanks.

    I initially tried to avoid this method but I cannot seem to find a viable alternative.

    Thanks for the help.

Please Sign in or register to post replies

Write your reply to:

Draft