468,115 Members | 2,068 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,115 developers. It's quick & easy.

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.
Nov 20 '08 #1
4 1301
On Nov 20, 10:22*am, Jon F <inva...@invalid.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.Host to get the name of domain from the
current request. It returns "www.site.com", 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.Host.ToLower().Split(".");
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 + "'";
Nov 20 '08 #2
On Thu, 20 Nov 2008 01:47:20 -0800 (PST), Alexey Smirnov wrote:
Greetings Alexey,

Alexey Smirnov wrote:
you can use Request.Url.Host to get the name of domain from the
current request. It returns "www.site.com", 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.
Nov 20 '08 #3
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.com/it/"
becomes "www.Website.com/default.aspx?lang=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.
Nov 20 '08 #4
On Nov 20, 4:59*pm, Jon F <inva...@invalid.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.com/it/"
becomes "www.Website.com/default.aspx?lang=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.
Nov 20 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Eric Osman | last post: by
1 post views Thread by Varsha | last post: by
32 posts views Thread by sandy | last post: by
28 posts views Thread by laredotornado | last post: by
42 posts views Thread by smerf | last post: by
11 posts views Thread by Bocah Sableng | last post: by
5 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.