#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2012
    Location
    Detroit area, MI
    Posts
    5
    Rep Power
    0

    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!

    Jason Weber
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2007
    Location
    Charlotte
    Posts
    412
    Rep Power
    144
    Originally Posted by jasonpaulweber
    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!

    Jason Weber
    Dude... you're totally there.

    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:

    Code:
    Session["Language"] = selectedLanguage;
    where selectedLanguage is what they chose in the list.

    In the other pages, to access that you could say:

    Code:
    languageChosen = Session["Language"].ToString();
    (not sure if the .ToString() is needed there, pretty sure it is).


    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).

    Good stuff.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2012
    Location
    Detroit area, MI
    Posts
    5
    Rep Power
    0

    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!

    Jason Weber

    Originally Posted by Ronster
    Dude... you're totally there.

    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:

    Code:
    Session["Language"] = selectedLanguage;
    where selectedLanguage is what they chose in the list.

    In the other pages, to access that you could say:

    Code:
    languageChosen = Session["Language"].ToString();
    (not sure if the .ToString() is needed there, pretty sure it is).


    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).

    Good stuff.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2007
    Location
    Charlotte
    Posts
    412
    Rep Power
    144
    Originally Posted by jasonpaulweber
    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!

    Jason Weber
    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?

    ussvision.com/about.aspx?lang=de
    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
    https://www.google.com/search?query=.net+query+strings

    The first hit is:
    http://www.codeproject.com/Articles/5876/Passing-variables-between-pages-using-QueryString

    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.

    This:
    ussvision.com/DE/about.aspx
    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

    • bunker17 agrees : Thats some descriptive help
    Last edited by Ronster; February 1st, 2012 at 10:43 AM.

IMN logo majestic logo threadwatch logo seochat tools logo