I have many resource strings, such as the second, all of which include some other resource string.
Instead of storing ready-made formatted strings ready for use, you can store the source materials to create real-format strings and add code to expand them before use. For example, you can store strings as follows:
BadRequestParameter: Potential bad request aborted before execution. SupportNumber: (123)456-7890 CallTechSupport: You need to call technical support at {SupportNumber}. RequiredParameterConstraint: {{0}} parameter requires a value. {BadRequestParameter} {CallTechSupport}
Of course, passing these strings to string.Format as-is will not work. You need to parse these lines, for example using RegExp s, and find all instances where you have a word between curly braces, not a number. Then you can replace each word with your own serial number and create an array of parameters based on the names you find between the curly braces. In this case, you will get these two values (pseudo-code):
formatString = "{{0}} parameter requires a value. {0} {1}"; // You replaced {BadRequestParameter} with {0} and {CallTechSupport} with {1} parameters = { "Potential bad request aborted before execution." , "You need to call technical support at (123)456-7890." };
Note: Of course, recursion is required to create this parameters array.
At this point, you can call string.Format to create your last line:
var res = string.Format(formatString, parameters);
This returns a string in which resource strings are previously replaced for your subscribers:
"{0} parameter requires a value. Potential bad request aborted before execution. You need to call technical support at (123)456-7890."
Callers can now use this string to format without worrying about other resource values.