Skip to content

Commit

Permalink
Translations actually load now!
Browse files Browse the repository at this point in the history
  • Loading branch information
reZach committed Jul 14, 2019
1 parent de9cde5 commit cba8d6e
Show file tree
Hide file tree
Showing 7 changed files with 362 additions and 345 deletions.
27 changes: 27 additions & 0 deletions ag.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"&file": "&file",
"&open": "&open",
"&close": "&close",
"&view": "&view",
"&reload": "&reload",
"toggle&FullScreen": "toggle&FullScreen",
"toggle&DeveloperTools": "toggle&DeveloperTools",
"help": "help",
"newUsersGuide": "newUsersGuide",
"learnMore": "learnMore",
"documentation": "documentation",
"communityDiscussions": "communityDiscussions",
"searchIssues": "searchIssues",
"changelog": "changelog",
"importData": "importData",
"clearLoadedData": "clearLoadedData",
"deleteData": "deleteData",
"myBudget": "myBudget",
"letsStart": "letsStart",
"passphrase": "passphrase",
"go": "go",
"newUserQuestionMark": "newUserQuestionMark",
"PleaseVisitThe": "PleaseVisitThe",
"newUsersGuideLowercase": "newUsersGuideLowercase",
"ifYoudLikeAWalkthroughPeriod": "ifYoudLikeAWalkthroughPeriod"
}
2 changes: 2 additions & 0 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
} from './store/configureStore';
import './app.global.css';

require("electron"); // Needed so we can call require("electron") in render processes

const store = configureStore(initialStore);


Expand Down
14 changes: 9 additions & 5 deletions app/main.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ import i18n from "./utils/i18n/i18n.config";
const { ipcMain } = require('electron');
const path = require("path");

// Done so we can pass getAppPath to render process
global.sharedObject = {
value: app.getAppPath()
};

export default class AppUpdater {
constructor() {
log.transports.file.level = 'info';
Expand Down Expand Up @@ -113,16 +118,15 @@ app.on('ready', async () => {
});


// not working...
ipcMain.on("language-changed", function(event, arg){

i18n.changeLanguage(arg, (err) => {
ipcMain.on("language-changed", function(event, arg){
i18n.changeLanguage(arg, (err) => {
if (err){
return console.log("couldn't change language");
}

menuBuilder.buildMenu();
event.returnValue = "value"; // need to return value
// https://stackoverflow.com/a/51360971/1837080
});
});
event.returnValue = "value";
});
26 changes: 22 additions & 4 deletions app/utils/i18n/i18n.config.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,45 @@
import config from "./i18n.languages.config";

const isDev = require('electron-is-dev');

let path = "";

// Because we force refresh the app once after we start
// because of some weird bug, the first time the below
// code runs it throws an error. The second time it succeeds.
// Don't know why...
if (!isDev){
try{
path = require('electron').remote.getGlobal('sharedObject').value;
} catch (e){
console.log(e);
}
}

const i18n = require('i18next');
const i18nextBackend = require('i18next-node-fs-backend');

const i18nextOptions = {
backend: {
// path where resources get loaded from
loadPath: './app/utils/i18n/locales/{{lng}}/{{ns}}.json',
loadPath: isDev ? "./app/utils/i18n/locales/{{lng}}/{{ns}}.json" :
`${path}.unpacked/app/utils/i18n/locales/{{lng}}/{{ns}}.json`,

// path to post missing resources
addPath: './app/utils/i18n/locales/{{lng}}/{{ns}}.missing.json',
addPath: isDev ? "./app/utils/i18n/locales/{{lng}}/{{ns}}.missing.json" :
`${path}.unpacked/app/utils/i18n/locales/{{lng}}/{{ns}}.missing.json`,

// jsonIndent to use when storing json files
jsonIndent: 4,
},
// debug: true,
debug: true,
interpolation: {
escapeValue: false
},
namespace: "transaction",
saveMissing: true,
saveMissingTo: "current",
fallbackLng: false,
fallbackLng: "en", // set to false when generating translation files locally
whitelist: config.whitelist,
react: {
wait: false
Expand Down
4 changes: 2 additions & 2 deletions docs/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ <h1>{{ site.title | default: site.github.repository_name }}</h1>
<div class="downloads">
<span>Downloads:</span>
<ul>
<li><a href="https://github.com/reZach/my-budget/releases/download/v3.3.1-beta/my-budget-3.3.1-beta.msi" class="button">Windows</a></li>
<li><a href="https://github.com/reZach/my-budget/releases/download/v3.3.1-beta/my-budget-3.3.1-beta.dmg" class="button">Mac</a></li>
<li><a href="https://github.com/reZach/my-budget/releases/download/v3.4.0-beta/my-budget-3.4.0-beta.msi" class="button">Windows</a></li>
<li><a href="https://github.com/reZach/my-budget/releases/download/v3.4.0-beta/my-budget-3.4.0-beta.dmg" class="button">Mac</a></li>
<li><a href="https://github.com/reZach/my-budget/releases/latest" class="button">Linux</a></li>
</ul>
</div>
Expand Down
Loading

0 comments on commit cba8d6e

Please sign in to comment.