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 8836619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:32:14+00:00 2026-06-14T09:32:14+00:00

I’ve been trying to follow the blog post found here . I’ve added a

  • 0

I’ve been trying to follow the blog post found here. I’ve added a new assembly that hosts my resource files (I used a separate assembly as the resources may need to be shared between multiple projects). I have added the following to my web.config:

  <system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="System.Web.Mvc.WebViewPage">
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
        <add namespace="MyResources.Resources"/>   <!-- New entry for resources -->
      </namespaces>
    </pages>
  </system.web.webPages.razor>

And I have gone though and added resource strings to a few files for testing purposes. Now the problem that I seem to be running into, is that I cannot set the resource to be anything other than the default. So for example, in the generated resource file designer there is the following:

    /// <summary>
    ///   Looks up a localized string similar to Log in was unsuccessful. Please correct the errors and try again..
    /// </summary>
    public static string Account_LoginUnsuccessful {
        get {
            return ResourceManager.GetString("Account_LoginUnsuccessful", resourceCulture);
        }
    }

If I set a breakpoint in this method, resourceCulture is NEVER anything but null. Even though I have tried the following:

In Global.asax.ca:

    protected void Application_AcquireRequestState(object sender, EventArgs e)
    {
        var culture = new System.Globalization.CultureInfo("fr");

        // Modify current thread's cultures            
        Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
        Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(culture.Name);
    } // End of Application_AcquireRequestState

In a base mvc controller that all of my other controller inherit:

    protected override void Initialize(System.Web.Routing.RequestContext requestContext)
    {
        SetCulture(requestContext.HttpContext.Request);
        base.Initialize(requestContext);
    }

    protected override void ExecuteCore()
    {
        SetCulture(Request);

        base.ExecuteCore();
    }

    protected override void Execute(System.Web.Routing.RequestContext requestContext)
    {
        SetCulture(requestContext.HttpContext.Request);
        base.Execute(requestContext);
    }

    protected override IAsyncResult BeginExecute(System.Web.Routing.RequestContext requestContext, AsyncCallback callback, object state)
    {
        SetCulture(requestContext.HttpContext.Request);

        metrics = Metrics.BeginTimer();
        return base.BeginExecute(requestContext, callback, state);
    }

    private void SetCulture(HttpRequestBase Request)
    {
        string cultureName = "fr";
        // Validate culture name
        cultureName = CultureHelper.GetImplementedCulture(cultureName); // This is safe

        // Modify current thread's cultures            
        Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(cultureName);
        Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
    }

Now, to my understanding setting the threading current culture should be causing my resource files culture to change. I can’t seem to get this working of the life of me (hence why I have tried setting the cultire in about ten different locations).

Any suggestions on what I am doing wrong here?

  • 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-06-14T09:32:15+00:00Added an answer on June 14, 2026 at 9:32 am

    Just to verify, try setting the language in a ActionFilterAttribute:

    public class ChangeLanguageAttribute : ActionFilterAttribute
    {
    
      public override void OnActionExecuting(
         ActionExecutingContext filterContext)
      {
         string languageCode = "fr";
    
         CultureInfo info =
           CultureInfo.CreateSpecificCulture(languageCode.ToString());
    
         Thread.CurrentThread.CurrentCulture = info;
         Thread.CurrentThread.CurrentUICulture = info;
      }
    }
    

    This is the exact code Im using, so I know this works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is

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.