0

I have a React app that has one index.html file with a bundle.js that holds all of the javascript for the app. The React app uses React Intl for localization.

In the case I have a 404 error, I want to show a 404 error page. I have created a static 404.html file to display the error message.

Since all of my logic for localization is in Index.html inside bundle.js, how would I be able to localize the text for my static 404.html page? Would I need to create a separate 404.html page for each language?

user5844628
  • 397
  • 1
  • 5
  • 15

1 Answers1

2

Rather than using a static html as 404 error page, use a component

<Route route="/" component={App}>
    <Route path=":area" component={Area}>
        <Route path=":city" component={City} />
        <Route path=":more-stuff" component={MoreStuff} />    
    </Route>
    <Route path="*" component={My404Component} />
</Route>

Then make sure your My404Component is locale aware using React Intl.

David
  • 15,894
  • 22
  • 55
  • 66