One page for several languages, but different domains?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jon F

    One page for several languages, but different domains?

    Hi everybody,

    I have a plain good ol' HTML website that currently hosts several localized
    versions of pages. That is, depending on the address/domain that users
    enter into their browser, the respective page is being shown in the
    underlying language, such as www.site.com -english or www.site.fr ->
    french.
    In the new ASP.Net application, all pages' textual content (text + tags)
    comes from a SQL Server database. While I could create one folder for each
    language plus the .aspx-pages, I wonder as to whether there isn't an easier
    way of dealing with this, like re-direction or assembling a QueryStrng
    (i.e. <?lang=it>) that would allow me to only create ONE page and still
    keep the addresses intact.

    Hence, browsing to www.site.com/page.aspx and www.site.fr/page.aspx would
    both lead to the *same* page.aspx (there would only be one for all
    languages) and the app would use the domain to determine the right language
    to be returned.

    Any insights/hints would be much appreciated!

    --
    Regards,
    J.
  • Alexey Smirnov

    #2
    Re: One page for several languages, but different domains?

    On Nov 20, 10:22 am, Jon F <inva...@invali d.comwrote:
    Hi everybody,
    >
    I have a plain good ol' HTML website that currently hosts several localized
    versions of pages. That is, depending on the address/domain that users
    enter into their browser, the respective page is being shown in the
    underlying language, such aswww.site.com-english orwww.site.fr->
    french.
    In the new ASP.Net application, all pages' textual content (text + tags)
    comes from a SQL Server database. While I could create one folder for each
    language plus the .aspx-pages, I wonder as to whether there isn't an easier
    way of dealing with this, like re-direction or assembling a QueryStrng
    (i.e. <?lang=it>) that would allow me to only create ONE page and still
    keep the addresses intact.
    >
    Hence, browsing towww.site.com/page.aspxandwww .site.fr/page.aspxwould
    both lead to the *same* page.aspx (there would only be one for all
    languages) and the app would use the domain to determine the right language
    to be returned.
    >
    Any insights/hints would be much appreciated!
    >
    --
    Regards,
    J.
    Hi Jon

    you can use Request.Url.Hos t to get the name of domain from the
    current request. It returns "www.site.c om", or "site.com" where you
    would need to check the last segment (1st level domain) "com".

    So, you can do something like this

    string[] name = Request.Url.Hos t.ToLower().Spl it(".");
    string test = name[name.length()-1];
    string lang;

    if (test == "com")
    lang == "en";

    if (test == "fr")
    lang == "fr";

    string sql = "select * from table where language code='"+lang + "'";

    Comment

    • Jon F

      #3
      Re: One page for several languages, but different domains?

      On Thu, 20 Nov 2008 01:47:20 -0800 (PST), Alexey Smirnov wrote:
      Greetings Alexey,

      Alexey Smirnov wrote:
      you can use Request.Url.Hos t to get the name of domain from the
      current request. It returns "www.site.c om", or "site.com" where you
      would need to check the last segment (1st level domain) "com".
      >
      So, you can do something like this
      (...)
      drat! I fumbled around with something almost identical in the beginning!
      Back then thought this couldn't work due to the paths/mappings: the old
      HTTP-app simply maps the domains to different directories on the server
      where, for each language, the respective htm-files are located.
      However, I didn't even think of the possibility to simply use the
      webspace's provider mapping so that all domains' requests are simply being
      sent to the single solution directory. That should actually work!

      The only drawback with this solution is that I need some additional stuff
      while being on localhost, but with a little additional work that should be
      feasible.

      Thanks for the pointer, Alexey!

      --
      Regards,
      J.

      Comment

      • Jon F

        #4
        Re: One page for several languages, but different domains?

        Hi again,
        The only drawback with this solution is that I need some additional stuff
        while being on localhost, but with a little additional work that should be
        feasible.
        done. I have added UrlMappings that will handle .../[code]/... paths and
        translate these into a QueryString so that i.e. "www.Website.co m/it/"
        becomes "www.Website.co m/default.aspx?la ng=it". The QueryString is then
        transformed into a language code. Hence, using localhost, I can sort of
        simulate the domain name and "navigate" to any given language.

        --
        Regards,
        J.

        Comment

        • Alexey Smirnov

          #5
          Re: One page for several languages, but different domains?

          On Nov 20, 4:59 pm, Jon F <inva...@invali d.comwrote:
          Hi again,
          >
          The only drawback with this solution is that I need some additional stuff
          while being on localhost, but with a little additional work that shouldbe
          feasible.
          >
          done. I have added UrlMappings that will handle .../[code]/... paths and
          translate these into a QueryString so that i.e. "www.Website.co m/it/"
          becomes "www.Website.co m/default.aspx?la ng=it". The QueryString is then
          transformed into a language code. Hence, using localhost, I can sort of
          simulate the domain name and "navigate" to any given language.
          >
          --
          Regards,
          J.
          Sounds great.

          There are a couple of other solutions available that can help you as
          well. One of them is HTTP module for URL rewriting, another one could
          be done if you have access to IIS - you can make different virtual
          directories, e.g. /de /en /fr pointed to the same (root) directory of
          your website and use Request.Url to get a "language code" from it.

          Comment

          Working...