Menu Content/Inhalt
Home arrow News arrow Latest arrow Default-language patch for sh404SEF published
Default-language patch for sh404SEF published PDF Print E-mail
Written by Jim DeLaHunt   
Tuesday, 04 March 2008

I have just made a patch to sh404SEF, one of the modules that extends the Joomla! content management system that runs this website. What the patch does is to ensure that all three of the languages supported on this website are treated equally in the URLs of this site.  Without the patch, the "/en/" tag for URLs of English-language content would be missing in some cases.

Making this patch involved understanding the complex PHP code of sh404SEF, and making surgical improvements in four places across two files.  

Details about this patch, and about how Joomla!, Joom!Fish, and sh404SEF interact, follow below the jump. 

Language support on jdlh.com

This site supports content in multiple languages (English, Japanese, and German so far), and also a user interface in multiple languages (the same three now, but could differ).  Each URL can include a language code between the domain name ("jdlh.com") and the path to the content. The language codes look like "/en/" for English, "/de/" for German, and "/ja/" for Japanese. The codes are based on RFC 3066 .  Where there is a language code in a URL, the site presents content localised for that language, to the extent possible. The content may not always available in that language, so the site may present the content in a fall-back language.

Where there is no language code in a URL, especially in the basic domain name http://jdlh.com/ ,
the site looks at the HTTP Accept-Language header to determine which language the user prefers, and redirects the browser to content with that language code.

Software used on jdlh.com

This site is built using Joomla!, a free software content management system (CMS). Version 1.0.x of Joomla!, which I use as of early 2008, can be coaxed into using UTF-8 text encoding and tolerating multi-lingual content. I add in Joom!Fish , a Joomla component which helps manage content in multiple parallel languages, and provides useful language utilities like that UI widget at the top of the page, to select between languages.

Joomla has many strengths, but easy-to-read URLs aren't among them. Left to itself, a Joomla URL is an opaque stream of numbers and codes. Turning those URLs into human-friendly URLs, which are concise, comprehensible to humans, and stable over time is the work of a "SEF" (Search-Engine-Friendly) component. Joomla has had several, but the first which satisifed us for jdlh.com is one called sh404SEF (see also sh404SEF on Joomla extensions and sh404SEF on siliana.net). 

There has been a tough interaction between Joomla, Joom!Fish, and sh404SEF (and its ill-starred predecessors).  Since mid-2006, Joomla would work with either of the other two, but not both together. Even as Joomla! moved forward to version 1.5.x, which has a better foundation for multilingual sites, I was held back to Joomla 1.0.x because Joom!Fish didn't support the new version yet.  Finally, in late February 2008, I discovered version 1.3.1 "TEST PR build 255" of sh404SEF, which seemed to work well with Joom!Fish (currently 1.8.2) and Joomla  (currently 1.0.15).

Default language handling and patch

However, sh404SEF's language handling didn't quite meet my needs. It treated "default" language — the single language Joomla! is set to support, not the extra languages for which Joom!Fish adds support — differently from the other languages.  For the other languages, it would insert the language code I wanted in the URL, i.e. "/de/" or "/ja/". However, for the default language, it wouldn't insert "/en/", it would just skip the language code.  This meant that the english-language homepage was "http://jdlh.com/" when I wanted "http://jdlh.com/en/". 

It turns out that fixing this involved changes to three areas in one file: sef404.php. sef404 is a single case statement of about 500 lines of PHP code, followed by about 800 lines of support functions. All of it has been through many hands, and it shows. Indentation and naming are inconsistent. There are few comments, and where you find them some are in English, some in Dutch. There's a hideously complex web of special-casing for various webservers and Joomla modules.

The first change was at line 48, where the code handles the homepage's URL. Where the plugin left this bare, I added a call to a function that checked the browser's accept-language headers and cookies to guess which language to use.  Then it redirected to a URL with that language code.

The second change was at line 867, where the code again handles the homepage's URL. (Why concentrate the homepage code in one location? Too easy!)  This area also had a peculiar expression. $shTemp is assigned the result of a boolean expression involving string equality and a string-typed expression, and thus it would get either the integer "1" or a string value. Later on, $shTemp is used as a string value. It looks like a bug to me. 

 $shTemp = ($v1 == $shHomeLink || ... (string expression here) );

The third change was at line 891. It deals with another part of the URL being built at line 867.

I also added about three diagnostic statements that write to the sh404SEF debugging log.  Finally, I made a change at line 49 of sh404sef.class.php that creates a parameter, h404SEF_DEFAULT_LANG_GETS_CODE, which I set to 1 to activate my changes, and which should be distributed as 0 to maintain the previous special-casing of the default language.

A patch archive with a diff of the changes, and the old and new files, is at:  http://jdlh.com/doc/sh404sef_default_lang2008/delahunt-DefaultLang-20080303.patch.zip .

My next step is to submit these changes to the developer of sh404SEF. 

Last Updated ( Tuesday, 04 March 2008 )
 
Next >

Sponsored Links

purchase Xenical without prescription buy herbal Maxalt purchasing Maxalt online without prescription buy xenical online uk buy online rx Orlistat without xenical express online where can i buy xenical without a perscription? no rx Orlistat with fedex where to purchase Orlistat no prescription no fees online pharmacy xenical no prescription xenical cost buy Xenical online without rx buy generic accutane without perscription cheap accutane online no prescription where to buy generic Maxalt online without a prescription Flomax effects where to buy Proscar buy cod Prednisone buy Valtrex without a prescription overnight delivery online Xenical Accutane from canada order Lasix usa cod cheap Accutane without rx zithromax fedex no prescription delivered zithromax buy proscar without rx from us pharmacy order no online rx Flomax buy Accutane no prescription needed Generic Accutane online how to purchase Lasix online without rx order Lasix usa cod Lasix without prescription shipped overnight express order Lasix without a rx overnight shipping Lasix non prescription for next day delivery purchase Lasix usa cod buy Buspar with a visa Maxalt overnight cod pharmacy Proscar purchase Valtrex without a prescription overnight shipping buy cheap Prednisone line buy Proscar cheap Cytotec no prescription cheap purchase Cytotec purchase online rx Lasix without purchase Lasix without purchase Zithromax without prescription pay cod Valtrex canadian pharmacy purchase Cytotec cod next day delivery online pharmacy Cytotec no prescription order Clomid 50 mg online Clomid pharmacy purchase cheap prescription Clomid Clomid visa Clomid online overnight delivery cod order Clomid online with overnight delivery Clomid without rx overnight shipping Clomid shipped cash on cheap order rx Cipro buy Cipro next day delivery order Cipro pharmacy Cipro without rx medications finpecia online order purchase Cipro online no membership Cipro without prescription overnight shipping buy Cipro online cod purchase Cipro pay pal online without rx buy Cipro without a rx overnight shipping buy Accutane online consultation us Accutane cheap Lasix online no prescription overnight cheap Lasix for sale online no prescription required purchase discount Lasix no rx Lasix without prescription mexico buy Xenical in mo Premarin with free fedex overnight order isotretinoin online cash on delivery|cheapest isotretinoin|buy isotretinoin cheap overnight) where can i order isotretinoin no prescription|cheapest isotretinoin|buy isotretinoin cheap overnight) proscar online prescription where to buy Cytotec in singapore buy Zovirax online pills order Valtrex without a rx overnight shipping buy valtrex ups Buy prednisone buy Orlistat online no rx purchase Orlistat prednisone without a perscription Valtrex for sale cheap Valtrex without a prescription buying valtrex Valtrex overnight delivery fed ex buy xenical next day delivery Prednisone non rx fedex overnight free where can i buy Valtrex without a rx order prescription free xenical buy Accutane on line without a rx xenical online next day shipping buy Xenical overnight buy Xenical cod purchase no perscription Valtrex Valtrex pharmacy buy buspar tablets without prescription Accutane buy cod order Accutane without rx Flomax usa Donepezil 0.625 mg purchase Premarin online without rx where to purchase cheap Zovirax no rx prednisone no physicisn consult buy cheap Zithromax how to by Xenical online Xenical order buy online Prednisone without rx buy Orlistat diet pill Orlistat effects i want to buy pregnizone without a prescription purchase Accutane without prescription to ship overnight cheap finpecia online where to buy Accutane no prescription no fees order Xenical cash on delivery order cheapest online Prednisone cheap Zithromax uk buy Prednisone australia Prednisone prices purchase Accutane free consultation buy Accutane online overseas purchase Accutane pay pal online without rx cheap order rx Zithromax online Xenical order purchase cheap online Lasix purchase finpecia without prescription finpecia online no prescription buy cheap online pharmacy Accutane purchase Accutane no visa without prescription