Martin Atkins (mart) wrote in lj_dev,
Martin Atkins
mart
lj_dev

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 LiveJournal.com-specific 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)

Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 8 comments