Copied to clipboard

Flag this post as spam?

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


  • Ashkan Sirous 38 posts 232 karma points
    Jun 06, 2016 @ 11:41
    Ashkan Sirous
    1

    Current Culture returns a wrong value

    Hi, I have a multi-lingual website. I've created a structure and I have 2 languages (en-us and da-Dk). The culture and language works fine on most pages, but it one when I check "System.Threading.Thread.CurrentThread.CurrentCulture" it returns "en-GB" :|

    I even tried to changed the language on the page to use da-DK to find the problem, but it still returns "en-GB".

    I am really confused, because there is no GB culture anywhere inside my whole structure. :O

  • Comment author was deleted

    Jun 06, 2016 @ 12:29

    Where in the code are you checking that? Could it be that the server lang is en-GB?

  • Ashkan Sirous 38 posts 232 karma points
    Jun 06, 2016 @ 12:50
    Ashkan Sirous
    0

    Hi Tim, Thanks for the reply. I have a surface controller, and in there I check the culture. (well I want to use GetDictionaryValue but it doesn't work because of wrong culture setting on the thread :|)

    I am testing the solution on my dev machine, and I've only installed en-us and da-dk on my system. (I have iis 8.5 on windows 8.1)

  • Bendik Engebretsen 105 posts 202 karma points
    Mar 20, 2017 @ 16:11
    Bendik Engebretsen
    0

    I have the exact same problem: down in my surface controller the CurrentCulture is always set to the default language, in my case en-US. Have you managed to solve this?

    EDIT: I just managed to solve this, see my post further down.

  • Comment author was deleted

    Jun 06, 2016 @ 12:51

    Strange indeed, and en-gb isn't setup as a language in Umbraco either?

  • Ashkan Sirous 38 posts 232 karma points
    Jun 07, 2016 @ 08:15
    Ashkan Sirous
    0

    Hi Tim, Thanks for reply. I don't have en-GB anywhere. I have 2 languages in Umbraco "English (US)" and "Danish". I don't understand how it find en-GB at all languages

  • Ashkan Sirous 38 posts 232 karma points
    Jun 07, 2016 @ 08:23
    Ashkan Sirous
    0

    everything related to languages in system

  • Manish 373 posts 932 karma points
    Jun 07, 2016 @ 06:58
    Manish
    0

    Hi Ashkan, enter image description here You can check like this

                          // Loop throgh all domains
                             foreach (var cultureitem in Domain.GetDomainsById(NodeId))
                            {
    
                             }
    

    Manish

  • Ashkan Sirous 38 posts 232 karma points
    Jun 07, 2016 @ 08:35
    Ashkan Sirous
    0

    Hi Manish,

    Thanks for the reply. I've tried your code.I have 2 domains, 1 with Danish language and the other with English-US. No trace of en-GB :|

  • Manish 373 posts 932 karma points
    Jun 07, 2016 @ 08:40
    Manish
    0

    Hi Ashkan

    Have you set culture like this

    enter image description here

    Manish

  • Ashkan Sirous 38 posts 232 karma points
    Jun 07, 2016 @ 08:46
    Ashkan Sirous
    0

    Hi Manish, Thanks again for reply. Yes. my domain settings is like this: enter image description here

  • Manish 373 posts 932 karma points
    Jun 07, 2016 @ 08:50
    Manish
    0

    Ashkan

    Have you cleared app_data folder?

    Manish

  • Manish 373 posts 932 karma points
    Jun 07, 2016 @ 09:14
    Manish
    0

    Hi Ashkan

    Can you retrieve culture on basis of node id as i gave you code above for this

    foreach (var cultureitem in Domain.GetDomainsById(pageId))
                                    {
    
                                            culture = cultureitem.Language.CultureAlias;
    
    }
    

    instead of using Thread.CurrentThread.CurrentCulture

    here why your solution is not working http://stackoverflow.com/questions/13915123/currentthread-currentuiculture-is-set-correctly-but-get-always-en-us

    So you can use umbraco library as i suggested above

    Manish

  • Bendik Engebretsen 105 posts 202 karma points
    Mar 20, 2017 @ 16:19
    Bendik Engebretsen
    0

    I had the exact same problem: down in my surface controller, the CurrentCulture was always set to the default culture, in my case en-US. However, I managed to solve it through the stackoverflow article mentioned above. The very simple solution was given in the last post by Shreyas. You simply add this to your web.config:

    <system.web>
      <globalization culture="auto" uiCulture="auto"/>
    </system.web>
    
Please Sign in or register to post replies

Write your reply to:

Draft