WebAIM - Web Accessibility In Mind

E-mail List Archives

Thread: Re: webaim-forum-d Digest V2004 #76

for

Number of posts in this thread: 2 (In chronological order)

From: Kurt M Bendl
Date: Fri, Apr 23 2004 10:53AM
Subject: Re: webaim-forum-d Digest V2004 #76
No previous message | Next message →

Patrizia:

If you are using something such as PHP, you "could" detect the language, and do conditionals inside your img tag to echo the appropriate content::

Stuff I found and put together...

<?
/*
////////////////////////////
// this will detect the Browser Language
// This can be hidden in the <head> or even called as a separate file
// with: <?php include ("footer.php"); ?>
//
////////////////////////////
*/

function BrowserLanguage(){

global $HTTP_SERVER_VARS;

if(isset($HTTP_SERVER_VARS["HTTP_ACCEPT_LANGUAGE"])) {

if(strpos($HTTP_SERVER_VARS["HTTP_ACCEPT_LANGUAGE"],"-") === false){
$browserlang = $HTTP_SERVER_VARS["HTTP_ACCEPT_LANGUAGE"];
}else {
list($browserlang) = explode ("-", $HTTP_SERVER_VARS["HTTP_ACCEPT_LANGUAGE"]);
}
}

return $browserlang;

} // BrowserLanguage

$bl=BrowserLanguage();
?>


This Next part can go before your image, I suppose....

<?php
if (!$bl) $LocalContent="";
elseif ($bl=="it") $LocalContent="Italian words";
elseif ($bl=="en") $LocalContent="English wordage";
elseif ($bl=="de") $LocalContent="German words";
else $LocalContent="";
?>

And finally, you can use it in the image tag like this....

<img src="something.gif" width="20" height="20" alt="<? echo $LocalContent;?>">


OKay, okay... I know there are many better ways to do this. I'm not much of a coder. But the server does all the work, and your CSS and html are still clean on the client side.

I've also just started working with Plone (plone.org). I bet there's a data that can be added to a modified Image content type to supply alternate ALT lang data. hmmm...??? Those Plone guys are smarter than me, maybe ask them.


my $0.02

Kurt



=======================================Kurt Bendl, Web Team Lead / Web Master
Information Technology
Miller IT Center, Room 109
University of Louisville
Louisville, KY 40292

502-852-5619 desk
1-800-334-UofL
kurt.bendl
@louisville.edu


>>> = EMAIL ADDRESS REMOVED = 4/22/2004 4:00:39 AM >>>
Patrizia:
the only way I know for handling multilingual text equivalents for
images is to use the OBJECT element. Adapted from the w3c document on
HTML 4.01:

<OBJECT data="canyon.png" type="image/png" lang="it">
Un inquadramento suggestivo del <span lang="en">Grand Canyon</span>.
</OBJECT>

Regards,
--
Giorgio Brajnik
______________________________________________________________________
Dip. di Matematica e Informatica | voice: +39 (0432) 55.8445
Universit

From: Jukka K. Korpela
Date: Sat, Apr 24 2004 7:28AM
Subject: Re: webaim-forum-d Digest V2004 #76
← Previous message | No next message

On Fri, 23 Apr 2004, Kurt M Bendl wrote:


> If you are using something such as PHP, you "could" detect
> the language, and do conditionals inside your img tag to echo the
> appropriate content::


But this does not address the question of using two languages inside a
single alt attribute.


Besides, we know that the Accept-Language header sent by the browser
is very often wrong, in the sense of not corresponding to the user's real
preferences. People just don't know those settings exist, so they use
e.g. browser that by default sends Accept-Language: en.


Moreover, if you play with that header in your PHP code, make double sure
that your code handles e.g.
Accept-Language: de;q=0.1,en-GB;q=0.9,en
properly. It is very common to use far too simplistic processing for it.


> <?php
> if (!$bl) $LocalContent="";
> elseif ($bl=="it") $LocalContent="Italian words";
> elseif ($bl=="en") $LocalContent="English wordage";
> elseif ($bl=="de") $LocalContent="German words";
> else $LocalContent="";
> ?>


Not a good idea. If there is no match for the language, it is still better
to include _some_ content, maybe in simplified English.


--
Jukka "Yucca" Korpela, http://www.cs.tut.fi/~jkorpela/