Closed freeqaz closed 8 years ago
A solution that I like is this:
locales = new locale.Locales(supportedLocales, 'unknown');
locales.best('zz-ZZ')
That would return 'unknown' and I wouldn't have to worry about external things modifying my state. It still doesn't help me if I set my default to 'en-US' and pass in 'en-US' though. It's useful to have a variable to tells me what happened exactly.
Released version 0.1.0 that includes the fix for this.
If I do the following:
I get returned 'en-US', as I expect.
The issue here is if I do something like...
In this case, I get returned 'en-US' but that's because it didn't find a match. There is no way for me to know that I defaulted, unless I attempt to hack around it like so:
This will return 'unknown' to me. Which I can then use to identify what happened. When coupled with this issue though -> https://github.com/jed/locale/issues/26 Now it's much not possible to understand the flow when the default is changed externally. I've got a PR open that has a possible fix, but I'm not crazy about it. There's a lot of logic for a simple goal. https://github.com/jed/locale/pull/25 Any ideas?