K
khaines
I've been pondering the best way of writing a piece of code that will,
when given a list of language options, select the one that best fullfills
what is being requested in an Accept-Language header.
i.e.
If one has a list of en, en-gb and es, and one gets an Accept-Language
header like this:
es-mx,es;q=0.8,en-us;q=0.5,en;q=0.3
the code would return the 'es' as the best matching language option.
Is there some already written Ruby code hiding in a project somewhere to
do this? Is there some piece of C library somewhere that I could just
write an extension for to do it? Can someone offer up a fast Ruby
implementation to handle Accept-Language decisions?
I've hacked out an almost right approach, but I'm not happy with it.
Thanks,
Kirk Haines
when given a list of language options, select the one that best fullfills
what is being requested in an Accept-Language header.
i.e.
If one has a list of en, en-gb and es, and one gets an Accept-Language
header like this:
es-mx,es;q=0.8,en-us;q=0.5,en;q=0.3
the code would return the 'es' as the best matching language option.
Is there some already written Ruby code hiding in a project somewhere to
do this? Is there some piece of C library somewhere that I could just
write an extension for to do it? Can someone offer up a fast Ruby
implementation to handle Accept-Language decisions?
I've hacked out an almost right approach, but I'm not happy with it.
Thanks,
Kirk Haines