Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 377999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:45:03+00:00 2026-05-12T14:45:03+00:00

I have my target language in Session[lang], which is either en or it. I

  • 0

I have my target language in Session[“lang”], which is either “en” or “it”. I have added this to the Site.master:

<script runat="server">
  void Page_Load(object sender, EventArgs e) {
    string lang = Session["lang"].ToString();
    System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(lang);
    System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CreateSpecificCulture(lang);
  }
</script>

Then I’d like to invoke a resource string like this:

<asp:Label ID="Label1" runat="server" Text="<%$ Resources:Global, test %>"></asp:Label>

I have two files in the App_GlobalResources, named Global.resx and Global.en.resx.

The problems is that no matter what is in the lang variable, I always get the results from the main Global.resx, and I never get the english version from Global.en.resx

I am doing this wrong entirely??

I tried putting the System.Threading… part in the Application_PreRequestHandlerExecute method in Global.asax.cs but the result was the same.

Thanks

PS: I am asking about a way to make this work in a simple way. If I was to use the complicate way, I’d go with this: http://helios.ca/2009/05/27/aspnet-mvc-and-localization/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T14:45:03+00:00Added an answer on May 12, 2026 at 2:45 pm

    i had the same dilema(how to implement localization) in my asp.net mvc app.

    I followed the instructions posted here and it works like a charm.

    So i created a folder named Localization under Content and then i create Resources resx files for each language i want to translate. Keep in mind that there is a convention for the resx file names. ie

    Resources.resx is the default fall back for everything.

    Resources.en-GB.resx is for english GB

    Resources.en-US.resx is for english US

    etc.

    Just make sure you follow the instructions posted in the link to embed and make the Resources available in all places in your app (views, controllers etc)

    Edit:

    I want to add that i ommited this line from web.config since i wanted to manually set the local from my app.

    <globalization uiCulture="auto" culture="auto"/>
    

    Instead i have created the following class:

        public class SmartController : Controller
    {
        public SmartController()
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US");
            System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");
        }
    }
    

    All controllers inherit from this class.

    Since this is an administrative set of the locale i have to set it from my apps settings. You could read it from Cookies and set it, or otherwise. This is imo the simplest solution for localization that i have encountered so far.

    Once implemented you can refer to any string you add by the following simple line of code, no extra code needed.

    <%= Resources.Strings.TranslatedTerm %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a b2Body which I would like to move at a certain target
I'm writing a compiler project which will produce assembly code as the target language.
Let's consider the below example. There, I have: target MAIN calls target t and
I have the Target Framework set to 2.0 on my windows application, yet when
I have set the target of the pic_form to a div (pic_target). The form
I have an ant target that echo's the content of an eclipse .project file,
I have the following target: <target name=promptforchoice> <input addproperty=choice> Copy the file?. [Y, n]
I have the following PHONY target in Makefile install: echo /usr/bin/shelldecrypt must be writable
I have a custom build target in a visual studio 2008 c# project. Is
(The target browser is IE8) I have a div that contains a list of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.