jeresig / i18n-node-2

Lightweight simple translation module for node.js / express.js with dynamic json storage. Uses common __('...') syntax in app and templates.
MIT License
507 stars 79 forks source link

Accept-Language header parsing ignores region tags? #21

Closed aseemk closed 10 years ago

aseemk commented 10 years ago

Currently line 224:

(accept.match(/(^|,\s*)([a-z]+)/g) || []).forEach(function(locale) {

https://github.com/jeresig/i18n-node-2/blob/master/i18n.js#L224

This only grabs the language tag, not the region tag, so it doesn't differentiate between e.g. simplified Chinese (zh-CN) and traditional (zh-TW).

@jed's locale and @mozilla's i18n-abide both have parsing code that takes region tags and even score into account.

E.g. https://github.com/mozilla/i18n-abide/blob/master/lib/i18n.js#L269-L295

Hope that helps!

jeresig commented 10 years ago

Just landed a pull request that fixes this.