Friday, October 28, 2005

Internationalization overdone

...I could've guessed it. A couple of posts ago, I wrote on offline webpages for some webapps. Yesterday, I encountered a really annoying bug in my solution

It's like this, once the pages are offline, you need a way to prevent broken links and references to other pages. Because I always use relative URI's for links in the web app, this is not too big of a problem. What is a problemn though is that my URI's contain queries, as in:


I use the URI to generate a filename, in order for the links to keep on working once the page is taken offline, and stored as a file. Unfortunately, the ? is not a valid character for a filename on Windows (wich is the target platform). So, I have substitute that for another character. I have to do that everywhere I link to a page, and of course when generating the filename.

Fortunately, the only cases of references to pages are through the javascript method, wich takes, among others, an URI parameter. And I already wrapped that call in my own function to provide the appropriate options to the opened window. So, there already was a single point receiveing all the URI's, making it easy enough to substitute the ? character for the tilde ~.

The only thing I needed now was a way of determining wheter the user was browsing offline. Because this is an Internet Explorers Solution, I used the document.protocol property for that. It the protocol is "Hypertext Transfer Protocol" we must use the ?; else, we must use the ~. Easy enough right?

As it turned out, the value returned by the document.protocol property depends upon the language of the IE installation. On my developer machine, that's English (US); on the users machines, it's Dutch. In wich case the value returned by document.protocol is "Hypertext Overdrachts protocol" or something like that.

It's of course all solvable, you just have to check for document.protocol.indexOf("HyperText")==0, but I really don't see why, and obviously would not expect, such a property to be Language dependent.



Scott Shepard said...

Try document.location.protocol

rpbouman said...

Hi Scott,

Thanks for that suggestion!

I will certainly try that next time.


Nowadays, many SQL implementations offer some form of aggregate string concatenation function. Being an aggregate function, it has the effe...