import React from 'react'
import * as ReactIntl from 'react-intl'

import languageResolver from './languageResolver'
import messagesFetcher from './messagesFetcher'

function wrappedReactIntlProvider(language, localizedMessages) {
  return function SanityIntlProvider(props) {
    return <ReactIntl.IntlProvider locale={language} messages={localizedMessages} {...props} />
  }
}

const SanityIntlProviderPromise = languageResolver.then(language => {
  return messagesFetcher.fetchLocalizedMessages(language).then(localizedMessages => {
    // TODO: ReactIntl.addLocaleData()
    return {
      ReactIntl,
      SanityIntlProvider: wrappedReactIntlProvider(language, localizedMessages)
    }
  })
})

module.exports = SanityIntlProviderPromise

@@ -388,32 +388,24 @@
 anityIntlPro
-viderPro
 mise = langu
@@ -435,16 +435,16 @@
 ge =%3E %7B%0A
+
   return
@@ -529,16 +529,132 @@
     
-// TODO:
+const languagePrexif = language.split('-')%5B0%5D%0A    const localeData = require(%60react-intl/locale-data/$%7BlanguagePrexif%7D%60)%0A   
  Rea
@@ -674,16 +674,26 @@
 aleData(
+localeData
 )%0A    re
@@ -811,16 +811,16 @@
  %7D)%0A%7D)%0A%0A
+
 module.e
@@ -845,16 +845,8 @@
 lPro
-viderPro
 mise

Add localeData for requested lanuage