florrain / locale

Browser locale negotiation for node.js
MIT License
257 stars 36 forks source link

No good way to unset default #12

Closed stuartf closed 10 years ago

stuartf commented 10 years ago

I'd like to be able to run without a default language set because when using this as an express middleware I want to have a different default language in different contexts so I need to know if there wasn't a best match.

I've accomplished this by setting locale.Locale.default to be null but the serialization turns that back into a string, so I have to do a string compare instead of just a truth check.

jed commented 10 years ago

heya @stuartf. this is a good point. do you think this is fixable in a backwards-compatible way?

(also, i'm not using this library much these days, so probably can't make api decisions as well as you can. i've added you as a collaborator, so feel free to move things forward.)

stuartf commented 10 years ago

@jed something like the attached PR would work for my use case, and it doesn't break the existing tests, I don't know how backward compatible it is for people who are already using the module.

jed commented 10 years ago

well, i can't imagine relying on setting a null default but expecting a string for comparison is a common case, so i would feel okay merging this.