Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
working out a poc with the contextBridge to expose fs to the i18n bac…
…kend module
- Loading branch information
Showing
5 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const { contextBridge } = require("electron"); | ||
const fs = require("fs"); | ||
|
||
console.log("ABC"); | ||
console.log(fs); | ||
|
||
contextBridge.exposeInMainWorld( | ||
"test", | ||
{ | ||
fs: fs | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import i18n from "i18next"; | ||
import { | ||
initReactI18next | ||
} from "react-i18next"; | ||
import i18nBackend from "i18next-node-fs-backend"; | ||
|
||
i18n | ||
.use(i18nBackend) | ||
.use(initReactI18next) | ||
.init({ | ||
backend: { | ||
loadPath: "./app/localization/locales/{{lng}}/{{ns}}.json", | ||
addPath: "./app/localization/locales/{{lng}}/{{ns}}.missing.json", | ||
jsonIndent: 2 | ||
}, | ||
debug: true, | ||
namespace: "translation", | ||
saveMissing: true, | ||
saveMissingTo: "current", | ||
fallbackLng: "en", // set to false when generating translation files locally | ||
}); | ||
|
||
export default i18n; | ||
|
||
// if (!i18n.isInitialized) { | ||
// i18n.use(i18nextBackend).init(i18nextOptions).then(function () { | ||
// i18n.changeLanguage(config.fallbackLng, (err) => { | ||
// if (err) { | ||
// return console.log("couldn't change language"); | ||
// } | ||
// }); | ||
// return true; | ||
// }).catch(function (err) { | ||
// console.error(err); | ||
// }); | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
import React from "react"; | ||
import ReactDOM from "react-dom"; | ||
//import "I18n/i18n.config"; | ||
import Root from "Core/root"; | ||
import store, { history } from "Redux/store/store"; | ||
|
||
console.error(window); | ||
console.error(window.test); | ||
|
||
ReactDOM.render( | ||
<Root store={store} history={history}></Root>, | ||
document.getElementById("target") | ||
); | ||
); |