I am trying to determine if it is possible to add a concatenated string to one of my local .resx files. This example should clarify:
Let's say I have a simple ASP.NET webpage composed of (1) a label whose text is an important keyword (2) an input with required field validation and (3) a button that causes validation to occur:
(lblMyInput)
(txtMyInput)
(rfvMyInput)
(btnSubmit)
Now, inside the resource file for this page, we want to localize the strings for the page's controls. However, for our error message, we want to use the literal name of the input's label. This is were my question is.
PSEUDOCODE: myPage.resx
(1) lblMyInput.Text = "Name"
(2) rfvMyInput.ErrorMessage = "The " + lblMyInput.Text + " field may not be left blank."
(3) btnSubmit.Text = "Submit/Validate"
Is there any way to pull off this type of concatenation of one resource file's string into another string within the same file?
Thanks!
One way to do it would be to have your two resx strings and work thusly:
Resource1: "Hello, this is a {0}"
Resource2: "Cookie"
And use the string parser to plop Resource2 into Resource1. A standard solution but not a very good one, as it requires the developer to know about the {0}. It also leads to localization issues if it ever goes off to translation.. not all languages have words in the same order as English.