Copied to clipboard

Flag this post as spam?

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


  • Sean Dooley 288 posts 527 karma points
    Feb 25, 2015 @ 17:33
    Sean Dooley
    0

    Multi-lingual site but current culture is always en-GB

    I've setup a multi-lingual site in Umbraco 4.9 and set the hostnames to the respective languages. Everything works as expected in our development environment using IIS 8.0.

    However the staging environment is using IIS 6.0, and using System.Threading.Thread.CurrentThread.CurrentCulture I can see that the current culture is always set to en-GB.

    Any ideas on how to resolve this issue?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Feb 25, 2015 @ 18:11
    Jan Skovgaard
    0

    Hi Sean

    Is there any possibility of upgrading the webserver? Not sure why it acts differently on your staging environment though.

    Have you checked that hostnames have been setup correctly on the staging environment?

    /Jan

  • Sean Dooley 288 posts 527 karma points
    Feb 25, 2015 @ 22:59
    Sean Dooley
    0

    Is there any possibility of upgrading the webserver? Not sure why it acts differently on your staging environment though.

    Would love to upgrade the server. Unfortunately it is not our server so we don't have any control over that.

    Have you checked that hostnames have been setup correctly on the staging environment?

    I've double checked ... triple checked them and as far as I know they are setup correctly.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Feb 26, 2015 @ 16:32
    Jan Skovgaard
    0

    Hi Sean

    Ok, then that's not an option.

    What is your site structure setup like? And what does the <useDomainPrefixes> look like in the /config/umbracoSettings.config file look like? Does it differ from local to live?

    /Jan

  • Sean Dooley 288 posts 527 karma points
    Feb 26, 2015 @ 17:01
    Sean Dooley
    0

    What is your site structure setup like?

    Content
    - GB : Domain: domain.com, Language: English (United Kingdom)
    - FR : Domain: domain.com/fr, Language: French (France)
    - DE : Domain: domain.com/de, Language: German (Germany)
    - IT : Domain: domain.com/it, Language: Italian (Italy)
    - ES : Domain: domain.com/es, Language: Spanish (Spain)
    - CN : Domain: domain.com/zh, Language: Chinese (Simplified, PRC)

    And what does the <useDomainPrefixes> look like in the /config/umbracoSettings.config file look like? Does it differ from local to live?

    /config/umbracoSettings.config is the same for both local and live

    <useDomainPrefixes>false</useDomainPrefixes>

    I maybe clutching at straws here, but do you know if it is possible to override the CurrentCulture settings? Maybe hooking into Application_Start with something like the following

    protected override void Application_Start(object sender, EventArgs e) {
      base.Application_Start(sender, e);
      // Insert your startup logic here
    }

    Keeping my fingers crossed

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Feb 26, 2015 @ 17:06
    Jan Skovgaard
    0

    Hi Sean

    Hmm, ok...I'm afraid that I have no clue about this one. Don't know if it's perhaps possible to tweak some web.config settings to get it working perhaps.

    Sorry, I don't know if it's possible. But I guess it can't hurt to try :)

    Btw...you should consider setting the useDomainPrefixes to true, since you can otherwise risk to have duplicate content issues.

    /Jan

  • Sean Dooley 288 posts 527 karma points
    Feb 27, 2015 @ 10:13
    Sean Dooley
    101

    Btw...you should consider setting the useDomainPrefixes to true, since you can otherwise risk to have duplicate content issues.

    Appreciate your help Jan. I'll set useDomainPrefixes to true.

    Solution

    I decided upon coding my own GetDictionaryItem XSLT extension. I created a new class in App_Code as follows

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using umbraco;
    using umbraco.NodeFactory;

    namespace Custom {
        [XsltExtension]
        public class Helpers {
            public Helpers() { }

            public static string GetDictionaryItem(string item) 
    {
                var result = "";
                var domains = umbraco.library.GetCurrentDomains(Node.getCurrentNodeId());
                if (domains != null && domains.Length > 0) {
                    var languageId = domains[0].Language.id;
                    var cultureAlias = domains[0].Language.CultureAlias;
                    result = new umbraco.cms.businesslogic.Dictionary.DictionaryItem(item).Value(languageId);
                }
                return result;
            }
        }
    }

    Then in any XSLT file where I've used umbraco.library:GetDictionaryItem, I've replaced that with my custom extension Custom.Helpers:GetDictionaryItem.

    <xsl:stylesheet 
     version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:umbraco.contour="urn:umbraco.contour" xmlns:twitter.library="urn:twitter.library" xmlns:Custom.Helpers="urn:Custom.Helpers" xmlns:PS.XSLTsearch="urn:PS.XSLTsearch"

    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets umbraco.contour twitter.library Custom.Helpers PS.XSLTsearch"> 
    <xsl:value-of select="Mosquito.Helpers:GetDictionaryItem('ViewAllNewsArticles')" />

    Not sure why umbraco.library:GetDictionaryItem isn't working as expected but the custom extension does the job.

Please Sign in or register to post replies

Write your reply to:

Draft