Language Selector

Overview

Project lead: Jeff Gordon (@jeffdavidgordon)

Purpose

Provides ASP, Javascript, Perl, and PHP appraoches for automatically linking to different language versions of the current page.

Benefits

  • Simplifies Web page maintenance by eliminating the need to hard code language links
  • Conforms to WCAG 2.0 AA

Recommended usage

Linking to different language versions of the current page.

Implementation

The language selector is available in both client side and server side implementations. The server side implementation is only required if you want the language selector functionality to work without the use of Javascript.

Client Side Implementation (Javascript/Jquery)

To enable secondary jQuery support, add class="wet-boew-langselect" to the language link.

<li id="gcwu-gcnb-lang"><a class="wet-boew-langselect" href="langselect/lang.php" lang="fr">Français</a></li>

Server Side Implementation (PHP, Perl, ASP)

Modify the language link on your web page so that its URL points to the location of this project's server-side script (e.g. /demos/langselect/lang.php). The language selector scripts rely on the HTTP_REFERER value but you can append the current URL to the query string when calling the script to improve accuracy:

http://www.gc.ca/cgi-bin/lang?http://www.gc.ca/index-eng.htm

Server Side Implementation (Server Side Includes)

See the wet-boew/wet-boew-ssi project where the language selector has been directly integrated into it.

Examples

Development

Known Issues

  • Some browsers can be configured to block the HTTP_REFERER value.

Version History