January 22nd, 2012, 10:36 PM
Have .resx files done, need entire website localized,
Localized so that, when a client goes to the website, they have the option to click on a flag and view the entire website in that language.
Using: Visual Studio 2010 / asp.net 4.0 / vb - I am NOT a programmer, just made my company's website using the above
I learned how to create a drop-down box to go to my language translation for that page, but that page only. When you go to the next, you'd have select from the drop down box all over again. I have 6 languages and all the .resx files in apps_globalresources directory.
I want them to be able to click a flag in the beginning, and view the entire website in their desired language. Is this simple, considering all I've done, or is this complex? Any guidance would be sincerely appreciated!
January 28th, 2012, 08:32 PM
Dude... you're totally there.
Originally Posted by jasonpaulweber
You need to set the selection from that first page into a SESSION VARIABLE. That variable would then be available on the other pages, to see what language they had chosen.
Session variables are one of the typical choices to retain state across a web app.
Looks something like this:
In the page where they make their choice, you would say:
where selectedLanguage is what they chose in the list.
Session["Language"] = selectedLanguage;
In the other pages, to access that you could say:
(not sure if the .ToString() is needed there, pretty sure it is).
languageChosen = Session["Language"].ToString();
You can have multiple Session variables. You just use the  (in C# at least), and then name the Session variable in the quotes. That Session variable is available to that user as long as their Session is valid (is lost if Session times out or something).
January 31st, 2012, 09:17 AM
Thank you -- site translating for entire session!
Hey, thanks for taking the time to respond, Ronster. I used what you had given me in your response, and just did a trial-and-error thing, upload, refresh, edit, upload, refresh, etc., etc., and finally got it to work! My site is now up to 8 languages and the end-user can select their own language and it lasts the entire session.
The only thing where I don't know if I'm wrong, is that the URL stays the same. I mean, like, if they're on ussvision.com/about.aspx, and they select another language, say, German, it puts the text in German, which is fine by me, but it doesn't change the URL, to, say, for instance, ussvision.com/DE/about.aspx or ussvision.com/about.aspx?lang=de or anything. I don't know if that's bad, or if I should look into rewriting that, or if I can leave it as is.
Nevertheless, thank you very much for taking the time to help. I appreciate it very much!
Originally Posted by Ronster
February 1st, 2012, 10:37 AM
Glad that helped, and you have it working. As for the URL bit... you didn't mention URL changing in your original post, so I didn't address that. Is it required for implementing multi-language support? Certainly not, as you've already demonstrated. Where that might help though, is being able to generate a BOOKMARKED url that could be saved (or emailed to someone) that would automatically call up the page with chosen language without user having to select it?
Originally Posted by jasonpaulweber
This would be an EASY change, and an *alternative* (or an addition) to the Session implementation.
the ?lang=de part is a "query string". You could pass that to each additional page, and page logic could parse that from the URL in order to know which language to use.
Just google .net query string
The first hit is:
and gives a good example. In your case, the variable you want to be passing is the chosen language. This would be very helpful, as if I was a German user, and I wanted to email that page to a friend... if it included the ?lang=DE part, then the page would load automatically in German.
is possibly more complicated? It presumes that you have a FOLDER for each language, with an about.aspx page in each one. You could implement a process which adds the language into the URL for each implemented language, assuming you have all the files there.
If you're able to associate your .resx files without having to do that, it makes it much easier than creating multiple folders, having multiple copies of the same file... ugh.
I like the ?lang=DE approach better. You might still want a session variable, where you check to see if it is set, and if so use that. If NOT set, you parse the URL to see if query string is used and if so set session variable to that....
Comments on this post
Last edited by Ronster; February 1st, 2012 at 10:43 AM.