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

  • Home
  • SEARCH
  • 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 6088101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:56:47+00:00 2026-05-23T11:56:47+00:00

I used to have something like this: We suggest you read our @Html.ActionLink(help page,

  • 0

I used to have something like this:

We suggest you read our @Html.ActionLink("help page", "Help", "Home") before
proceeding.

nice and clean. then I decided we needed to internationalise the app. I couldn’t figure out a better way to deal with the above than to store the following string in the resource file:

We suggest you read our [HelpPage] before proceeding.

and then on the view I have to do:

@MvcHtmlString.Create(this.Resource("Help").ToString()
   .Replace("[HelpPage]",
       @Html.ActionLink("help page", "Help", "Home").ToString()
   )
)

What other strategies can you use to internationalize using Razor?

this.Resource() is a page extension that calls .GetLocalResourceObject() and returns an MvcHtmlString

  • 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-23T11:56:48+00:00Added an answer on May 23, 2026 at 11:56 am

    so here’s what I ended up writing:

    public static class PageExtensions
    {
        public static MvcHtmlString Resource(
            this WebViewPage page, string key, 
            Dictionary<string, MvcHtmlString> tokenMap
        ) {
            HttpContextBase http = page.ViewContext.HttpContext;
            string text = (string) http.GetLocalResourceObject(page.VirtualPath, key);
            return new TagReplacer(text, tokenMap).ToMvcHtmlString();
        }
    

    where the tag replacements gets done like this:

    public class TagReplacer
    {
        Dictionary<string, MvcHtmlString> tokenmap;
        public string Value { get; set; } 
    
        public TagReplacer(string text, Dictionary<string, MvcHtmlString> tokenMap)
        {
            tokenmap = tokenMap;
    
            Regex re = new Regex(@"\[.*?\]", RegexOptions.IgnoreCase);
            Value = re.Replace(text, new MatchEvaluator(this.Replacer));
        }
    
        public string Replacer(Match m)
        {
            return tokenmap[m.Value.RemoveSet("[]")].ToString();
        }
    
        public MvcHtmlString ToMvcHtmlString()
        {
            return MvcHtmlString.Create(Value);
        }
    }
    

    so in my code I can now call it like this:

    @{
       Dictionary<string, MvcHtmlString> tagmap = new Dictionary<string, MvcHtmlString>() {
                    { "HelpPage", Html.ActionLink("help page", "Help", "Home") }
                };
    }
    

    and elsewhere:

    @this.Resource("Help", tagmap)
    

    any suggestions for improvement most welcome

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

Sidebar

Related Questions

In our code we used to have something like this: *(controller->bigstruct) = ( struct
I used to have my permalinks to standard format, something like http://example.com/?page_id=2 . Now
This is the code i have. The NSDictionary did used to be something, but
I have an in-memory table that might looks something like this: Favorite# Name Profession
I think I may have used a repeater when I should have used something
i have something similar to the following... used a python script to JSON to
I have used getopt in Python and was hoping there would be something similar
I'm working on a security project in Javascript (something I honestly have not used),
It's something that's bugged me in every language I've used, I have an if
I came across a few articles like this one , which suggest that some

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.