react-boilerplate icon indicating copy to clipboard operation
react-boilerplate copied to clipboard

How to use Ant Design LocaleProvider with React-Boilerplate ?

Open beeeku opened this issue 9 years ago • 2 comments

We have started using React-Boilerplate . Also we are trying to integrate Ant Design for it's awesome components .

From the docs of Ant Design I have created a wrapper around AppWrapper of React-boilerplate like this -

import { LocaleProvider } from 'antd';
import enUS from 'antd/lib/locale-provider/en_US'; 
return ( 
<LocaleProvider locale={enUS}> 
<AppWrapper> 
...
</AppWrapper>
</LocaleProvider> 
);

And it's working perfect for antd components.

I wanted to know how can I use this with i18n of react-boilerplate . Or if this above way is a correct way of doing this ? In the case of React-Boilerplate the locale is stored in Redux. For antd to be able to update locale when the app does, must be inserted inside the Redux provider, otherwise it will not have access to the locale state.

So app.js needs to become something like:


<Provider store={store}>
    <LanguageProvider messages={messages}>
        <LocaleProvider locale={...}>
            <Router ... />
        </LocaleProvider>
    </LanguageProvider>
</Provider>,

Unfortunately this is not enough, since antd's LocaleProvider does not take a simple locale id string as its argument, but rather an object with the locale info itself.

This means that it is not possible to just insert in the wrapper chain as above. So how do I do this ?

beeeku avatar May 22 '17 09:05 beeeku

Closing due to inactivity

vineyardbovines avatar Feb 16 '18 21:02 vineyardbovines

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar May 29 '18 01:05 lock[bot]