src/localization.js
function createHeadContextWith(createContext, bundles) {
  const [bundle] = bundles;

  if (!bundle) {
    return Promise.resolve(null);
  }

  return bundle.fetch().then(resources => {
    const ctx = createContext(bundle.lang);
    resources
      // Filter out resources which failed to load correctly (e.g. 404).
      .filter(res => res !== null)
      .forEach(res => ctx.addMessages(res));
    // Save the reference to the context.
    contexts.set(bundle, ctx);
    return ctx;
  });
}
function createHeadContextWith(createContext, bundles) {
  const [bundle] = bundles;

  if (!bundle) {
    return Promise.resolve(null);
  }

  return bundle.fetch().then(resources => {
    const ctx = createContext(bundle.lang);
    resources
      // Filter out resources which failed to load correctly (e.g. 404).
      .filter(res => res !== null)
      .forEach(res => ctx.addMessages(res));
    // Save the reference to the context.
    contexts.set(bundle, ctx);
    return ctx;
  });
}
function createHeadContextWith ( createContext , bundles ) { const [ bundle ] = bundles ; if ( ! bundle ) { return Promise . resolve ( null ) ; } return bundle . fetch ( ) . then ( resources => { const ctx = createContext ( bundle . lang ) ; resources // Filter out resources which failed to load correctly (e.g. 404). . filter ( res => res !== null ) . forEach ( res => ctx . addMessages ( res ) ) ; // Save the reference to the context. contexts . set ( bundle , ctx ) ; return ctx ; } ) ; }
Create a `MessageContext` for the first bundle in the fallback chain.

Fetches the bundle's resources and creates a context from them.

@param   {Array<ResourceBundle>} bundle
@param   {Function}              createContext
@returns {Promise<MessageContext>}
@private
Create a MessageContext for the first bundle in the fallback chain .