Reputation: 51937
I have a web application that works in several languages. On the client side, I store words in JavaScript arrays like this:
var SomeSectionOfThePage = ['word1', 'word2', ... ]
And then when I'm generating the HTML dynamically in the client I do this:
var TheHTML = '<div>' + SomeSectionOfThePage[0] + '</div>';
I keep the dictionary arrays in a different .js files and when I need to generate the page, the URL for the JavaScript file is resolved according to the user's language. This works great because I don't need to touch the code to modify words in the language dictionaries.
I want to do the same thing for the back-end: I want to have different resource files that get loaded depending on the user's language.
For now, this is what I'm doing for generating HTML on the server:
<div><asp:Literal runat="server" ID="SomeID" /></div>
And then in my code-behind, I do something like this:
switch (TheLanguage)
{
case 1:
SomeID.Text = "hi";
case 2:
SomeID.Text = "bonjour";
}
As you can see, the text is stored in my C# file and that works well for now but I want to move the text to a resource file. How do I store the words so that they're easy to restore in C# when I generating the HTML? I'm looking for ideas on how to put this functionality together.
Upvotes: 0
Views: 1237
Reputation: 3328
You may want to start here with this information:
Localization with Resource Files
Upvotes: 1