Farsi translations for react admin
Farsi translations for React-Admin, the frontend framework for building admin applications on top of REST/GraphQL services.
npm install --save ra-language-farsi
yarn add ra-language-farsi
import farsiMessages from 'ra-language-farsi';
import polyglotI18nProvider from 'ra-i18n-polyglot';
const messages = {
'fa': farsiMessages,
};
const i18nProvider = polyglotI18nProvider(locale => messages[locale], 'fa');
<Admin i18nProvider={i18nProvider}>
...
</Admin>
Material UI is already supprting RTL, so we can add its support to React Admin using these 2 steps:
dir
property to rtl
in your root elements (like body).Using HTML (public/index.html):
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root" dir="rtl"></div>
</body>
Using CSS style:
body {
direction: rtl;
}
Or Pure JS:
document.getElementsByTagName("body")[0].setAttribute('dir', 'rtl');
const theme = deepmerge(defaultTheme, { direction: “rtl” });
3. Configure RTL style plugin ([MUI doc](https://mui.com/material-ui/customization/right-to-left/#3-configure-rtl-style-plugin))
```javascript
import { CacheProvider } from "@emotion/react";
import createCache from "@emotion/cache";
import { prefixer } from "stylis";
import rtlPlugin from "stylis-plugin-rtl";
// Configure cache
const cacheRtl = createCache({
key: "muirtl",
stylisPlugins: [prefixer, rtlPlugin],
});
const App = () => (
<CacheProvider value={cacheRtl}>
<Admin theme={theme}>
// ...
</Admin>
</CacheProvider>
);
This translation is licensed under the BSD Licence, and sponsored by Hamid FzM.