import React from 'react' ; import { NextComponentType } from 'next' ; import { BaseContext , NextPageContext } from 'next/dist/next-server/lib/utils' ; import { Locale } from '@island.is/shared/types' ; import { LocaleProvider , MessagesDict } from './LocaleContext' ; interface Props { pageProps : { locale : Locale ; messages : MessagesDict ; } ; } export const appWithLocale = < C extends BaseContext = NextPageContext , IP = { } > ( WrappedComponent ) => { const AppWithLocale = ( props ) => { return ( < LocaleProvider locale = { props . pageProps . locale } messages = { props . pageProps . messages } > < WrappedComponent { ... props } / > < /LocaleProvider>); } ; AppWithLocale . getInitialProps = WrappedComponent . getInitialProps ; return AppWithLocale ; } ; export default appWithLocale ;