Update hook i18n to consider new locales filename
'use strict';

/**
 * Module dependencies
 */

// Node.js core.
const path = require('path');

// Public node modules.
const _ = require('lodash');

/**
 * i18n hook
 */

module.exports = function (strapi) {
  const hook = {

    /**
     * Default options
     */

    defaults: {
      i18n: {
        defaultLocale: 'en_US',
        modes: ['query', 'subdomain', 'cookie', 'header', 'url', 'tld'],
        cookieName: 'locale'
      }
    },

    /**
     * Initialize the hook
     */

    initialize: function (cb) {
      if (_.isPlainObject(strapi.config.i18n) && !_.isEmpty(strapi.config.i18n)) {
        strapi.middlewares.locale(strapi.app);
        strapi.app.use(strapi.middlewares.i18n(strapi.app, {
          directory: path.resolve(strapi.config.appPath, strapi.config.paths.config, 'locales'),
          locales: strapi.config.i18n.locales,
          defaultLocale: strapi.config.i18n.defaultLocale,
          modes: strapi.config.i18n.modes,
          cookieName: strapi.config.i18n.cookieName,
          extension: '.json'
        }));
      }

      cb();
    }
  };

  return hook;
};

'use strict';

/**
 * Module dependencies
 */

// Node.js core.
const path = require('path');

// Public node modules.
const _ = require('lodash');

/**
 * i18n hook
 */

module.exports = function (strapi) {
  const hook = {

    /**
     * Default options
     */

    defaults: {
      i18n: {
        defaultLocale: 'en',
        modes: ['query', 'subdomain', 'cookie', 'header', 'url', 'tld'],
        cookieName: 'locale'
      }
    },

    /**
     * Initialize the hook
     */

    initialize: function (cb) {
      if (_.isPlainObject(strapi.config.i18n) && !_.isEmpty(strapi.config.i18n)) {
        strapi.middlewares.locale(strapi.app);
        strapi.app.use(strapi.middlewares.i18n(strapi.app, {
          directory: path.resolve(strapi.config.appPath, strapi.config.paths.config, 'locales'),
          locales: strapi.config.i18n.locales,
          defaultLocale: strapi.config.i18n.defaultLocale,
          modes: strapi.config.i18n.modes,
          cookieName: strapi.config.i18n.cookieName,
          extension: '.json'
        }));
      }

      cb();
    }
  };

  return hook;
};
