Martin Atkins (mart) wrote in lj_dev,
Martin Atkins

Selecting en_GB (and, I guess, other sub-languages)

I'm having a bit of trouble testing this, simply because my browser keeps trying to be clever, or gets cookies and sends them when I don't want it to, but it looks like BML can't auto-select en-gb from Accept-Language. From what I read in the code, this makes sense because it reads up to ten \w (letters, digits, underscores) from the start of the string and uses that.

The HTTP spec says that if my browser requests en-gb specifically, it should get only British English or nothing. As it happens, my browser is configured to ask for "en-gb, en, es" in that order, so giving me en to satisfy the second is of course acceptable, and I'd not quibble if it wasn't for the fact that I've seen the code and I know that it's not doing what it appears to be doing! ;)

Since the spec says that en-gb or en-us aren't allowed to fall back on generic 'en' unless it's also present in the list, this doesn't require any special logic... just allow BML to "see" the letters after the hypen too, and it should 'just work' if en_GB is renamed to en-gb, which also has the benefit that it sets it aside from en_LJ, which isn't a special kind of English but instead a extension to the phrases in normal English.

Revised regex, then... /^([a-z]{1,5}([\-_][a-z]{1,5})?)/i;, which should match en, en-gb, en_LJ, EN-GB and de, but not match en-gb_LJ, which will never exist. (because I said so! :p)


  • cl-journal livejournal client

    Hey everyone, I'd like to present a livejournal client that I wrote to fulfill my needs but maybe there are other people that can find it…

  • SessionGenerate and ljloggedin

    Are there any information after release 86 and changes in cookies scheme to use sessiongenerate? It returns ljsession key, but this key is not enough…

  • Retrieving comments

    Hi, Is there a way to retrieve a list of comments made by user XXX (which may or may be not the currently logged in user) in the journals of users…

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded