Skip to content

Commit

Permalink
fix: interpret 'no' as 'nb' in locale data
Browse files Browse the repository at this point in the history
  • Loading branch information
wessberg committed Oct 26, 2020
1 parent 90796c7 commit b74f2a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wessberg/polyfiller",
"version": "0.0.107",
"version": "0.0.108",
"description": "Never worry about polyfills again.",
"files": [
"dist/**/*.*",
Expand Down
10 changes: 9 additions & 1 deletion src/service/polyfill-builder/polyfill-builder-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ import {IPolyfillRequest} from "../../polyfill/i-polyfill-request";

const SYNC_OPTIONS = {cwd: __dirname};

function normalizeLocale(locale: string): string {
switch (locale) {
// nb and no are identical languages from a data perspective
case "no":
return "nb";
}
}

function selectMetaPaths<Meta extends Exclude<IPolyfillDictEntryBase["meta"], undefined>>(value: Meta[keyof Meta], context: PolyfillContext): string[] {
if (typeof value === "string") return [value];
if (Array.isArray(value)) return value;
Expand Down Expand Up @@ -180,7 +188,7 @@ export class PolyfillBuilderService implements IPolyfillBuilderService {
for (const localeDir of selectMetaPaths(meta.localeDir, request.context)) {
const locale = new (Intl as any).Locale(requestedLocale);
let addedLocale = false;
for (const currentLocale of [locale.baseName, locale.language]) {
for (const currentLocale of new Set([locale.baseName, normalizeLocale(locale.baseName), locale.language, normalizeLocale(locale.language)])) {
const localePathInput = join(rootDirectory, localeDir, `${currentLocale}.js`);
const resolvedLocalePath = sync(localePathInput, SYNC_OPTIONS);
if (resolvedLocalePath != null) {
Expand Down

0 comments on commit b74f2a2

Please sign in to comment.