<commit_before>import polka from 'polka';
import { parse } from 'url';
import next from 'next';
import { join, basename } from 'path';
import IntlPolyfill from 'intl';
import glob from 'glob';
import accepts from 'accepts';
import { readFileSync } from 'fs';
import favicon from 'serve-favicon';
import renderAndCache from './caching';
import posts from '../posts.json';

import atom from '../lib/atom';
import jsonfeed from '../lib/jsonfeed';
import manifest from '../lib/manifest';

const dev = process.env.NODE_ENV !== 'production';
const app = next({ dev });
const PORT = process.env.PORT || 3000;
const handle = app.getRequestHandler();

process.on('unhandledRejection', error => {
  throw error;
});

const languages = glob.sync('../lang/*.json').map(f => basename(f, '.json'));

const parseLocale = locale =>
  Array.isArray(locale) ? locale[0].split('-')[0] : locale.split('-')[0];

const localeDataCache = new Map();
const getLocaleDataScript = locale => {
  if (!localeDataCache.has(locale)) {
    const localeDataFile = require.resolve(`react-intl/locale-data/${locale}`);
    const localeDataScript = readFileSync(localeDataFile, 'utf8');
    localeDataCache.set(locale, localeDataScript);
  }
  return localeDataCache.get(locale);
};

Intl.NumberFormat = IntlPolyfill.NumberFormat;
Intl.DateTimeFormat = IntlPolyfill.DateTimeFormat;

// eslint-disable-next-line import/no-dynamic-require, global-require
const getMessages = locale => require(`../lang/${locale}.json`);
<commit_msg>check if locale is an asterisk and return 'en'<commit_after>import polka from 'polka';
import { parse } from 'url';
import next from 'next';
import { join, basename } from 'path';
import IntlPolyfill from 'intl';
import glob from 'glob';
import accepts from 'accepts';
import { readFileSync } from 'fs';
import favicon from 'serve-favicon';
import renderAndCache from './caching';
import posts from '../posts.json';

import atom from '../lib/atom';
import jsonfeed from '../lib/jsonfeed';
import manifest from '../lib/manifest';

const dev = process.env.NODE_ENV !== 'production';
const app = next({ dev });
const PORT = process.env.PORT || 3000;
const handle = app.getRequestHandler();

process.on('unhandledRejection', error => {
  throw error;
});

const languages = glob.sync('../lang/*.json').map(f => basename(f, '.json'));

const parseLocale = locale => {
  if ((Array.isArray(locale) && locale[0].includes('*')) || locale === '*') {
    return 'en';
  } else if (Array.isArray(locale)) return locale[0].split('-')[0];
  return locale.split('-')[0];
};

const localeDataCache = new Map();
const getLocaleDataScript = locale => {
  if (!localeDataCache.has(locale)) {
    const localeDataFile = require.resolve(`react-intl/locale-data/${locale}`);
    const localeDataScript = readFileSync(localeDataFile, 'utf8');
    localeDataCache.set(locale, localeDataScript);
  }
  return localeDataCache.get(locale);
};

Intl.NumberFormat = IntlPolyfill.NumberFormat;
Intl.DateTimeFormat = IntlPolyfill.DateTimeFormat;

// eslint-disable-next-line import/no-dynamic-require, global-require
const getMessages = locale => require(`../lang/${locale}.json`);

{'fraction_non_alphanumeric': 0.1652892561983471, 'fraction_numerical': 0.00540368722186904, 'mean_word_length': 4.926553672316384, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2920181', 'n_tokens_mistral': 963, 'n_tokens_neox': 960, 'n_words': 254}