locked
2nd language pages RRS feed

  • Question

  • User-412070860 posted

    Hi,

     I've an existing website in English language and would like to add to add another language to it.

    for each english page there will be a 2nd language paralel page, but the 2nd language page will not be different in many aspect (so I will not use localization for it)

    users will expect to find the English website in domain1.com and the 2nd language website in domain2.com

    I'm thinking to make all the 2nd language pages in a subfolder /2ndlang and then to redirect pages according to their URL's.

     for example:

    1.if someone types domain1.com - it will go to the root folder.
    2. domain2.com will redirect /2ndlang folder
    3. domain2.com/page1.aspx will redirect to domain2.com/2ndlang/page1.aspx

    My questions are: 

    1. what is the best way to implement this? (code examples will be great!) 

    2. Is this method the best way to go about it?


    any ideas will be most appreciated, 

    Thanks!
     


     

    Thursday, September 27, 2007 6:34 AM

Answers

  • User80740001 posted

    I think I got your point,

    for your multi-language web site use one page with two resources, one for each language and redirect the two domains to the same web site, now accourding to the domain the requests the page the page will be displayed in the specified language,

    you can do it as follow,

    protected void Page_Load(object sender, EventArgs e)

    {

        if (Request.Url.AbsolutePath.Contains("domain1"))// english for example

        {

                Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo("en-US");

                 Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");

        }

         else if (Request.Url.AbsolutePath.Contains("domain2"))// french for example

        {

                Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo("fr-FR");

                Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CreateSpecificCulture("fr-FR");

        }

     }
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 27, 2007 5:24 PM
  • User1187105292 posted

     System.Threading.Thread is the full nomenclature.

     If you use Visual Studio, go to the help pages and use the Index feature, filling in the class name.  Or google on asp.net and the class name. If often google because it's faster than waiting for the help page to load.
     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 27, 2007 6:47 PM

All replies

  • User1187105292 posted

    I don't understand!  If the pages are almost identical except for the language of the text, why NOT use localization?  Isn't that exactly what it is for?

    Why have duplicated code structures when duplicated code structures are not needed?  Why go to the trouble of building a page-redirecting process when you wouldn't need it if your pages were localized?

    Thursday, September 27, 2007 11:01 AM
  • User1827201912 posted

    Agreed. Localization is the solution for this. If you create duplicate pages, maintaining them will become a problem soon.

    Check this for an example of how localisation can be used :

    http://quickstarts.asp.net/QuickStartv20/aspnet/doc/localization/localization.aspx

     

    HTH,
    Suprotim Agarwal

    -----
    http://www.dotnetcurry.com
    -----

    Thursday, September 27, 2007 11:20 AM
  • User-412070860 posted

     well, the 2nd language is RTL + Unicode, which it makes a lot of trouble in localization + some functions are using different data fields and different conditions in each language version.

    Also, I will need 2 domain in any case - one domain to show directly the 1st language, and 2nd domain for the 2nd local domain (not .com) to show the 2nd lang.

     

    Thursday, September 27, 2007 11:32 AM
  • User80740001 posted

    Hi,

    For the RTL language please reffer to: http://forums.asp.net/t/1076962.aspx

    Thursday, September 27, 2007 4:17 PM
  • User1187105292 posted

     Why do you think you need two domains because you have two languages?  That simply is not true.

    Multi-lingual sites typically allow the user to choose what language they want to read the site in, often by using a graphic of the country's flag.

    The information would be held in a session variable.  If someone registers at the site, the session variable would be loaded from their saved profile.

    See http://www.eurolingua.com/Index_French.htm for an example.  (I've been looking up "Learn French in France" opportunities for next summer for the last several weeks, so I know this particular feature from a user perspective very well!) 

    Thursday, September 27, 2007 4:41 PM
  • User-412070860 posted

    I know I can do it without 2 domains. the things is that there are 2 domains needed each domain as a default address for each language (and in a local country domain name)

    Question remains: the content should be localized according to typed domain name and not according to client locality setting. 

     any ideas how to solve this?
     

    Thursday, September 27, 2007 4:59 PM
  • User80740001 posted

    I think I got your point,

    for your multi-language web site use one page with two resources, one for each language and redirect the two domains to the same web site, now accourding to the domain the requests the page the page will be displayed in the specified language,

    you can do it as follow,

    protected void Page_Load(object sender, EventArgs e)

    {

        if (Request.Url.AbsolutePath.Contains("domain1"))// english for example

        {

                Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo("en-US");

                 Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");

        }

         else if (Request.Url.AbsolutePath.Contains("domain2"))// french for example

        {

                Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo("fr-FR");

                Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CreateSpecificCulture("fr-FR");

        }

     }
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 27, 2007 5:24 PM
  • User-412070860 posted

     Thanks! Thats seems like what I'm looking for!

    How is Thread defined? could you please direct me to an example code that compiles / complete this code ? 

    Thursday, September 27, 2007 5:56 PM
  • User1187105292 posted

     System.Threading.Thread is the full nomenclature.

     If you use Visual Studio, go to the help pages and use the Index feature, filling in the class name.  Or google on asp.net and the class name. If often google because it's faster than waiting for the help page to load.
     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 27, 2007 6:47 PM
  • User-412070860 posted

     I can't get your code to build, I've added  using System.Threading; yet I get "  System.Globalization.CultureInfo' is a 'type', which is not valid in the given context"

     Thanks,


     

    Friday, September 28, 2007 8:36 AM
  • User1827201912 posted

    Hi,

    Change the code given by Bashar to

    if (Request.Url.AbsolutePath.Contains("domain1"))// english for example

    {

    Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

    Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");

    }

    else if (Request.Url.AbsolutePath.Contains("domain2"))// french for example

    {

    Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");

    Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CreateSpecificCulture("fr-FR");

    }

     

    HTH,
    Suprotim Agarwal

    -----
    http://www.dotnetcurry.com
    -----

     

    Sunday, September 30, 2007 2:56 PM