How to resolve text with Localization macros according to a specific culture

HelenaG Grulichova asked on July 19, 2011 03:41

How to resolve text with Localization macros according to a specific culture

Correct Answer

HelenaG Grulichova answered on July 19, 2011 03:41

You can use a code like:

string output = ResHelper.RegExLocalize.Replace(input, LocalizedStringMatch);

where input is a string with localization macros.

Then you need to specify LocalizedStringMatch, for example:

/// <summary>
/// Match evaluator for the string localization
/// </summary>
/// <param name="m">Regular expression match</param>
private static string LocalizedStringMatch(System.Text.RegularExpressions.Match m)
{
string expression = m.Groups[1].ToString();
return ResHelper.GetString(expression, culture);
}

where culture is a global string variable which contains a culture code (i.e. “en-US”).

-hg-
0 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.