Add translation support
Change-Id: I8cc38cd00683ce6f0ef8f62eb9eeddfc84c52a34
This commit is contained in:
parent
a854f981c6
commit
3c72960bd1
@ -18,6 +18,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"prop-types": "^15.7.2",
|
||||
"ra-language-german": "^2.1.2",
|
||||
"react": "^16.12.0",
|
||||
"react-admin": "^3.1.3",
|
||||
"react-dom": "^16.12.0",
|
||||
|
17
src/App.js
17
src/App.js
@ -1,9 +1,22 @@
|
||||
import React from "react";
|
||||
import { Admin, Resource } from "react-admin";
|
||||
import { Admin, Resource, resolveBrowserLocale } from "react-admin";
|
||||
import polyglotI18nProvider from "ra-i18n-polyglot";
|
||||
import dataProvider from "./dataProvider";
|
||||
import germanMessages from "./i18n/de";
|
||||
import englishMessages from "./i18n/en";
|
||||
|
||||
// TODO: Can we use lazy loading together with browser locale?
|
||||
const messages = {
|
||||
de: germanMessages,
|
||||
en: englishMessages,
|
||||
};
|
||||
const i18nProvider = polyglotI18nProvider(
|
||||
locale => (messages[locale] ? messages[locale] : messages.en),
|
||||
resolveBrowserLocale()
|
||||
);
|
||||
|
||||
const App = () => (
|
||||
<Admin dataProvider={dataProvider}>
|
||||
<Admin dataProvider={dataProvider} i18nProvider={i18nProvider}>
|
||||
<Resource name="data" />
|
||||
</Admin>
|
||||
);
|
||||
|
5
src/i18n/de.js
Normal file
5
src/i18n/de.js
Normal file
@ -0,0 +1,5 @@
|
||||
import germanMessages from "ra-language-german";
|
||||
|
||||
export default {
|
||||
...germanMessages,
|
||||
};
|
5
src/i18n/en.js
Normal file
5
src/i18n/en.js
Normal file
@ -0,0 +1,5 @@
|
||||
import englishMessages from "ra-language-english";
|
||||
|
||||
export default {
|
||||
...englishMessages,
|
||||
};
|
@ -8974,6 +8974,11 @@ ra-language-english@^3.2.0:
|
||||
resolved "https://registry.yarnpkg.com/ra-language-english/-/ra-language-english-3.2.0.tgz#2ca13b767d834b43fefd128f48e452449f812b61"
|
||||
integrity sha512-/XmwYWoQoB4MBkkzBCbg/ykCuRGjHQOHLk2ik6n1aM10AWHxiiJNyRw2aoLzH7Vc5rcp4BBJQCuhT+DgfYIJ2Q==
|
||||
|
||||
ra-language-german@^2.1.2:
|
||||
version "2.1.2"
|
||||
resolved "https://registry.yarnpkg.com/ra-language-german/-/ra-language-german-2.1.2.tgz#d183093d470ab499ece91838cb67222db88f2e4f"
|
||||
integrity sha512-N+BaBP0z98ujaKVlAMIKTfWHgmTiWD8sPQrU5vA3+b5zY9U0mMB4VjvU8sQQPR7rZE0gsRgS/X4V6ycDtNL6iQ==
|
||||
|
||||
ra-ui-materialui@^3.2.1:
|
||||
version "3.2.1"
|
||||
resolved "https://registry.yarnpkg.com/ra-ui-materialui/-/ra-ui-materialui-3.2.1.tgz#8e0d9b74c36e9f800b8b766d67dfc720b821f561"
|
||||
|
Loading…
Reference in New Issue
Block a user