Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Dynamic English/French links

Reply
Thread Tools

Dynamic English/French links

 
 
Jim Royal
Guest
Posts: n/a
 
      01-12-2005
Living in Montreal, I am required to produce web content in both
official languages. So, my English sites contain links to French
content, and vice versa.

For database-driven sites, pulling up the content in the right language
is merely part of the query. But for static sites, all I've been able
to do is provide a link to the main page in the alternate language, but
that's a bit awkward for the site visitor.

Is there a way to pick up the URL for the current page, rewrite it on
the fly, and call up the equivalent page in the alternate language? For
example, to change this:

/en/services/general.shtml

into this:

/fr/services/general.shtml

Javascript? PHP?

Any suggestions are welcome.

--
Jim Royal
"Understanding is a three-edged sword"
http://JimRoyal.com
 
Reply With Quote
 
 
 
 
Philip Ronan
Guest
Posts: n/a
 
      01-12-2005
Jim Royal wrote:

> Living in Montreal, I am required to produce web content in both
> official languages. So, my English sites contain links to French
> content, and vice versa.
>
> For database-driven sites, pulling up the content in the right language
> is merely part of the query. But for static sites, all I've been able
> to do is provide a link to the main page in the alternate language, but
> that's a bit awkward for the site visitor.


But is it really all that likely your visitors will want to look at BOTH
languages? Just one or the other, surely?

I think the best option would be to use a LINK element and let the UAs deal
with it or not as they see fit. Something like this should do:

<LINK title="French version" type="text/html" rel="alternate" hreflang="fr"
href="/fr/services/general.shtml">

(see <http://www.w3.org/TR/REC-html40/struct/links.html#h-12.3.3>.)

Alternatively, if you're using an Apache server you should consider using
its content negotiation features.

> Is there a way to pick up the URL for the current page, rewrite it on
> the fly, and call up the equivalent page in the alternate language? For
> example, to change this:
>
> /en/services/general.shtml
>
> into this:
>
> /fr/services/general.shtml
>
> Javascript? PHP?


If you want to do it this way, add a form with a select menu
("French","English") and process it using client-side javascript (based on
the value of location.href) or server-side PHP (based on the value of
$_SERVER[¹HTTP_REFERER¹]).

Phil

--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/


 
Reply With Quote
 
 
 
 
hyweljenkins@hotmail.com
Guest
Posts: n/a
 
      01-12-2005
Of course. Move your files to .php instead and use
$_SERVER["SCRIPT_NAME"] or $_SERVER["PHP_SELF"] to get the current
document name, and write the links to other languages accordingly.
You'll need to break it up using explode() and then replace the
language array element with the target language identifier.

--
Hywel

 
Reply With Quote
 
Jan Faerber
Guest
Posts: n/a
 
      01-13-2005
Jim Royal wrote:


> Javascript? PHP?


Possible solutions:

#) The user can set the language and it will be saved in a cookie,
so when he comes again the selected language can be remembered.

#) The user can not set the language - it will be automatically detected.





--
Jan

http://linux.janfaerber.com
 
Reply With Quote
 
Jim Royal
Guest
Posts: n/a
 
      01-13-2005
In article <BE0AA085.28556%(E-Mail Removed)>, Philip Ronan
<(E-Mail Removed)> wrote:

> But is it really all that likely your visitors will want to look at BOTH
> languages? Just one or the other, surely?


Often true, but not always. However, my thought is for people entering
into the site via deep linking. It would be nice to be able to flip the
page to the alternate language without forcing people to try and guess
where in the site hierarchy the page is located.

> I think the best option would be to use a LINK element and let the UAs deal
> with it or not as they see fit. Something like this should do:
>
> <LINK title="French version" type="text/html" rel="alternate" hreflang="fr"
> href="/fr/services/general.shtml">


Interesting. However, this would require encoding the URL manually into
each page, which is just as much work as making manual HREFs.

> Alternatively, if you're using an Apache server you should consider using
> its content negotiation features.


I will look into this.

> > Is there a way to pick up the URL for the current page, rewrite it on
> > the fly, and call up the equivalent page in the alternate language?

>
> If you want to do it this way, add a form with a select menu
> ("French","English") and process it using client-side javascript (based on
> the value of location.href) or server-side PHP (based on the value of
> $_SERVER[¹HTTP_REFERER¹]).


This is probably what I'll do in the short term. Thanks muchly for the
input.

--
Jim Royal
"Understanding is a three-edged sword"
http://JimRoyal.com
 
Reply With Quote
 
Jim Royal
Guest
Posts: n/a
 
      01-13-2005
In article <(E-Mail Removed) .com>,
<(E-Mail Removed)> wrote:

> Of course. Move your files to .php instead and use
> $_SERVER["SCRIPT_NAME"] or $_SERVER["PHP_SELF"] to get the current
> document name, and write the links to other languages accordingly.
> You'll need to break it up using explode() and then replace the
> language array element with the target language identifier.


I'll keep this in mind for the future. Thanks.

--
Jim Royal
"Understanding is a three-edged sword"
http://JimRoyal.com
 
Reply With Quote
 
Jim Royal
Guest
Posts: n/a
 
      01-13-2005
In article <ktrFd.8053$(E-Mail Removed)>, Jan Faerber
<jancfaerber_spider@monkey_hotmail.com> wrote:
> #) The user can set the language and it will be saved in a cookie,
> so when he comes again the selected language can be remembered.
>
> #) The user can not set the language - it will be automatically detected.


I don't think either is a good idea, frankly. This is not like a
selection for country in an e-commerce site where alternate country
selections would be of no use. Some people do indeed want to be able to
see both.

--
Jim Royal
"Understanding is a three-edged sword"
http://JimRoyal.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Update to FAQ - Relative URLs for In-page Links and Links to Notes Garrett Smith Javascript 14 05-26-2009 04:50 PM
FF Crashes on Links within Links Puma Firefox 10 02-17-2009 07:12 PM
Make A Shorter Link - no new links accepted, old links still work. why? Computer Support 7 01-02-2007 09:45 PM
Site Links and Physical WAN Links =?Utf-8?B?RW5mb1BhdWw=?= MCSE 2 03-22-2005 09:23 AM
Exchange Links < Western Cartoon Cards > Exchange Links www.westerncartooncards.ca HTML 2 07-12-2004 07:59 PM



Advertisments