I have a series of Resource Files for Localization purposes.In Drupal, there are something called tokens, which are some patterned text that it is replaced by the server when it is called.
Example:
Resource file in English:
I have this localization text in my resource file in English, and I would like to display to $[user] how this works.
Resource file in Spanish:
Yo tengo este texto localizado en el archivo de recursos en español y quisiera enseñarle al $[user] cómo esto funciona.
Then, after some parsing I would replace the token with the correct details.
My current approach has been the following:
public class LocalizationParser
{
    private Dictionary<string, dynamic> Tokens { get; set; }
    public LocalizationParser()
    {
        Tokens = new Dictionary<string, dynamic>();
        Tokens.Add("$[user]", HttpContext.Current.User.Identity.Name);
    }
    public string ParseResource(string text)
    {
        foreach(var token in Tokens)
        {
            text.Replace(token.Key, token.Value);
        }
        
        return text;
    }
}
I know I have a huge problem that I am getting all these values populated, and there WILL be an unnecessary performance impact. I know that if I could call a method which could retrieve the correct value only if the dictionary key has been found, there wouldn't be a huge overhead into it.
What is the correct way to do this in c#? (Currently using ASP.NET MVC 5 with EF 6.1)
 
     
    