Allow 'en' in the list of supported locales #9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For newer versions of Moment (2.21.0+),
moment.localeData('unknown')
returns the localeData of the currently set locale, instead ofnull
. This means that if the locale hasn't been set explicitly, it will return the localeData of the built-in 'en' locale.Starting with 1.0.6, this plugin checks for unknown locales by retrieving the localeData of the locales in the "localesToKeep" parameter, and comparing them to the localeData of the currently set locale.
However, when "en" is also included in "localesToKeep", the plugin will produce the "Moment.js doesn’t include a locale you specified: en" error. Considering that this is the default locale that can't be removed, the message is quite unclear.
With this PR, I remove the "en" locale from the list of locales to keep, before it will check for missing locales or produce the final list of locale abbreviations. In practice, this means that
['en']
will be treated similarly to[]
for the localesToKeep parameter.