mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2025-12-06 02:30:47 -08:00
feat: add translations to dialog
This commit is contained in:
parent
a97732153a
commit
25af011e06
15 changed files with 108 additions and 67 deletions
|
|
@ -45,5 +45,13 @@
|
|||
"SynchronizationFinish": "同步完成",
|
||||
"PrepareCloneOnlineWiki": "准备克隆线上Wiki",
|
||||
"StartFetchingFromGithubRemote": "正在拉取Github远端仓库的数据,需要的时间取决于网速和仓库大小,请耐心等待"
|
||||
},
|
||||
"Dialog": {
|
||||
"NeedCorrectTiddlywikiFolderPath": "需要传入正确的路径,而此路径无法被 TiddlyWiki 识别。",
|
||||
"CantFindWorkspaceFolderRemoveWorkspace": "无法找到之前还在该处的工作区文件夹!本应存在于此处的文件夹可能被移走了!是否移除工作区?",
|
||||
"WorkspaceFolderRemoved": "工作区文件夹被移走",
|
||||
"RemoveWorkspace": "移除工作区",
|
||||
"DontCare": "不管",
|
||||
"PathPassinCantUse": "传入的路径无法使用"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
27
package-lock.json
generated
27
package-lock.json
generated
|
|
@ -3485,7 +3485,7 @@
|
|||
},
|
||||
"is-fullwidth-code-point": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz",
|
||||
"resolved": "https://registry.npm.taobao.org/is-fullwidth-code-point/download/is-fullwidth-code-point-2.0.0.tgz",
|
||||
"integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=",
|
||||
"dev": true
|
||||
},
|
||||
|
|
@ -3830,7 +3830,7 @@
|
|||
},
|
||||
"async": {
|
||||
"version": "0.9.2",
|
||||
"resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz",
|
||||
"resolved": "https://registry.npm.taobao.org/async/download/async-0.9.2.tgz",
|
||||
"integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=",
|
||||
"dev": true
|
||||
},
|
||||
|
|
@ -5963,7 +5963,7 @@
|
|||
},
|
||||
"chromium-pickle-js": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/chromium-pickle-js/-/chromium-pickle-js-0.2.0.tgz",
|
||||
"resolved": "https://registry.npm.taobao.org/chromium-pickle-js/download/chromium-pickle-js-0.2.0.tgz",
|
||||
"integrity": "sha1-BKEGZywYsIWrd02YPfo+oTjyIgU=",
|
||||
"dev": true
|
||||
},
|
||||
|
|
@ -9557,7 +9557,7 @@
|
|||
},
|
||||
"ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"resolved": "https://registry.npm.taobao.org/ms/download/ms-2.0.0.tgz",
|
||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
|
||||
"dev": true
|
||||
}
|
||||
|
|
@ -11190,6 +11190,11 @@
|
|||
"lodash.merge": "^4.6.2"
|
||||
}
|
||||
},
|
||||
"i18next-fs-backend": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/i18next-fs-backend/-/i18next-fs-backend-1.0.7.tgz",
|
||||
"integrity": "sha512-aAZ3rvshe1Zbl6JSCWrWWqbZS5JpmVNG+84YqLcgdYcm9uAxzw4xWxnA/a3044Nm2PKXE62CT+pIZjk7OEYtTw=="
|
||||
},
|
||||
"iconv-lite": {
|
||||
"version": "0.4.24",
|
||||
"resolved": "https://registry.npm.taobao.org/iconv-lite/download/iconv-lite-0.4.24.tgz",
|
||||
|
|
@ -11287,7 +11292,7 @@
|
|||
},
|
||||
"import-lazy": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/import-lazy/-/import-lazy-2.1.0.tgz",
|
||||
"resolved": "https://registry.npm.taobao.org/import-lazy/download/import-lazy-2.1.0.tgz",
|
||||
"integrity": "sha1-BWmOPUXIjo1+nZLLBYTnfwlvPkM=",
|
||||
"dev": true
|
||||
},
|
||||
|
|
@ -13965,7 +13970,7 @@
|
|||
"dependencies": {
|
||||
"pify": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz",
|
||||
"resolved": "https://registry.npm.taobao.org/pify/download/pify-3.0.0.tgz",
|
||||
"integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
|
|
@ -16182,7 +16187,7 @@
|
|||
},
|
||||
"proto-list": {
|
||||
"version": "1.2.4",
|
||||
"resolved": "https://registry.npmjs.org/proto-list/-/proto-list-1.2.4.tgz",
|
||||
"resolved": "https://registry.npm.taobao.org/proto-list/download/proto-list-1.2.4.tgz",
|
||||
"integrity": "sha1-IS1b/hMYMGpCD2QCuOJv85ZHqEk=",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
|
|
@ -17855,7 +17860,7 @@
|
|||
},
|
||||
"semver-compare": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/semver-compare/-/semver-compare-1.0.0.tgz",
|
||||
"resolved": "https://registry.npm.taobao.org/semver-compare/download/semver-compare-1.0.0.tgz",
|
||||
"integrity": "sha1-De4hahyUGrN+nvsXiPavxf9VN/w=",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
|
|
@ -18851,7 +18856,7 @@
|
|||
},
|
||||
"strip-json-comments": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz",
|
||||
"resolved": "https://registry.npm.taobao.org/strip-json-comments/download/strip-json-comments-2.0.1.tgz",
|
||||
"integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=",
|
||||
"dev": true
|
||||
},
|
||||
|
|
@ -19608,7 +19613,7 @@
|
|||
},
|
||||
"truncate-utf8-bytes": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/truncate-utf8-bytes/-/truncate-utf8-bytes-1.0.2.tgz",
|
||||
"resolved": "https://registry.npm.taobao.org/truncate-utf8-bytes/download/truncate-utf8-bytes-1.0.2.tgz",
|
||||
"integrity": "sha1-QFkjkJWS1W94pYGENLC3hInKXys=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
|
|
@ -20071,7 +20076,7 @@
|
|||
},
|
||||
"utf8-byte-length": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/utf8-byte-length/-/utf8-byte-length-1.0.4.tgz",
|
||||
"resolved": "https://registry.npm.taobao.org/utf8-byte-length/download/utf8-byte-length-1.0.4.tgz",
|
||||
"integrity": "sha1-9F8VDExm7uloGGUFq5P8u4rWv2E=",
|
||||
"dev": true
|
||||
},
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
"graphql-hooks": "4.5.0",
|
||||
"i18next": "^19.6.3",
|
||||
"i18next-electron-fs-backend": "^1.3.4",
|
||||
"i18next-fs-backend": "^1.0.7",
|
||||
"is-url": "1.2.4",
|
||||
"jimp": "0.14.0",
|
||||
"lodash": "4.17.19",
|
||||
|
|
|
|||
|
|
@ -31,4 +31,5 @@ module.exports = {
|
|||
DESKTOP_PATH,
|
||||
LOG_FOLDER,
|
||||
LOCALIZATION_FOLDER,
|
||||
isDev,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ const path = require('path');
|
|||
const { compact, truncate, trim } = require('lodash');
|
||||
const { GitProcess } = require('dugite');
|
||||
const { logger } = require('./log');
|
||||
const i18n = require('./i18n');
|
||||
|
||||
const getGitUrlWithCredential = (rawUrl, username, accessToken) =>
|
||||
trim(`${rawUrl}.git`.replace('https://github.com/', `https://${username}:${accessToken}@github.com/`));
|
||||
|
|
@ -58,7 +59,7 @@ async function initWikiGit(wikiFolderPath, githubRepoUrl, userInfo, isMainWiki)
|
|||
const logProgress = message => logger.notice(message, { handler: 'createWikiProgress', function: 'initWikiGit' });
|
||||
const logInfo = message => logger.info(message, { function: 'initWikiGit' });
|
||||
|
||||
logProgress('Log.StartLocalGitInitialization');
|
||||
logProgress(i18n.t('Log.StartLocalGitInitialization'));
|
||||
const { login: username, email, accessToken } = userInfo;
|
||||
logInfo(
|
||||
`Using gitUrl ${githubRepoUrl} with username ${username} and accessToken ${truncate(accessToken, {
|
||||
|
|
@ -67,9 +68,9 @@ async function initWikiGit(wikiFolderPath, githubRepoUrl, userInfo, isMainWiki)
|
|||
);
|
||||
await GitProcess.exec(['init'], wikiFolderPath);
|
||||
await commitFiles(wikiFolderPath, username, email);
|
||||
logProgress('Log.StartConfiguringGithubRemoteRepository');
|
||||
logProgress(i18n.t('Log.StartConfiguringGithubRemoteRepository'));
|
||||
await credentialOn(wikiFolderPath, githubRepoUrl, userInfo);
|
||||
logProgress('Log.StartBackupToGithubRemote');
|
||||
logProgress(i18n.t('Log.StartBackupToGithubRemote'));
|
||||
const { stderr: pushStdError, exitCode: pushExitCode } = await GitProcess.exec(
|
||||
['push', 'origin', 'master:master', '--force'],
|
||||
wikiFolderPath,
|
||||
|
|
@ -77,11 +78,11 @@ async function initWikiGit(wikiFolderPath, githubRepoUrl, userInfo, isMainWiki)
|
|||
await credentialOff(wikiFolderPath);
|
||||
if (isMainWiki && pushExitCode !== 0) {
|
||||
logInfo(pushStdError);
|
||||
const CONFIG_FAILED_MESSAGE = 'Log.GitRepositoryConfigurateFailed';
|
||||
const CONFIG_FAILED_MESSAGE = i18n.t('Log.GitRepositoryConfigurateFailed');
|
||||
logProgress(CONFIG_FAILED_MESSAGE);
|
||||
throw new Error(CONFIG_FAILED_MESSAGE);
|
||||
} else {
|
||||
logProgress('Log.GitRepositoryConfigurationFinished');
|
||||
logProgress(i18n.t('Log.GitRepositoryConfigurationFinished'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -117,8 +118,7 @@ async function getSyncState(wikiFolderPath, logInfo) {
|
|||
async function assumeSync(wikiFolderPath, logInfo, logProgress) {
|
||||
if ((await getSyncState(wikiFolderPath, logInfo)) === 'equal') return;
|
||||
|
||||
const SYNC_ERROR_MESSAGE =
|
||||
'Log.SynchronizationFailed';
|
||||
const SYNC_ERROR_MESSAGE = i18n.t('Log.SynchronizationFailed');
|
||||
logProgress(SYNC_ERROR_MESSAGE);
|
||||
throw new Error(SYNC_ERROR_MESSAGE);
|
||||
}
|
||||
|
|
@ -140,7 +140,7 @@ async function getGitDirectory(wikiFolderPath, logInfo, logProgress) {
|
|||
return path.resolve(`${gitPath1}/${gitPath2}`);
|
||||
}
|
||||
}
|
||||
const CONFIG_FAILED_MESSAGE = 'Log.NotAGitRepository';
|
||||
const CONFIG_FAILED_MESSAGE = i18n.t('Log.NotAGitRepository');
|
||||
logProgress(CONFIG_FAILED_MESSAGE);
|
||||
throw new Error(`${wikiFolderPath} ${CONFIG_FAILED_MESSAGE}`);
|
||||
}
|
||||
|
|
@ -217,7 +217,7 @@ async function continueRebase(wikiFolderPath, username, email, logInfo, logProgr
|
|||
while (hasNotCommittedConflict) {
|
||||
loopCount += 1;
|
||||
if (loopCount > 1000) {
|
||||
const CANT_SYNC_MESSAGE = 'Log.CantSynchronizeAndSyncScriptIsInDeadLoop';
|
||||
const CANT_SYNC_MESSAGE = i18n.t('Log.CantSynchronizeAndSyncScriptIsInDeadLoop');
|
||||
logProgress(CANT_SYNC_MESSAGE);
|
||||
throw new Error(CANT_SYNC_MESSAGE);
|
||||
}
|
||||
|
|
@ -239,7 +239,7 @@ async function continueRebase(wikiFolderPath, username, email, logInfo, logProgr
|
|||
logInfo(rebaseContinueStdError);
|
||||
logInfo(`commitStdError when ${repositoryState}`);
|
||||
logInfo(commitStdError);
|
||||
const CANT_SYNC_MESSAGE = 'Log.CantSyncInSpecialGitStateAutoFixFailed';
|
||||
const CANT_SYNC_MESSAGE = i18n.t('Log.CantSyncInSpecialGitStateAutoFixFailed');
|
||||
logProgress(CANT_SYNC_MESSAGE);
|
||||
throw new Error(`${repositoryState} ${CANT_SYNC_MESSAGE}`);
|
||||
}
|
||||
|
|
@ -247,7 +247,7 @@ async function continueRebase(wikiFolderPath, username, email, logInfo, logProgr
|
|||
rebaseContinueStdError.startsWith('CONFLICT') || rebaseContinueStdOut.startsWith('CONFLICT');
|
||||
}
|
||||
|
||||
logProgress('Log.CantSyncInSpecialGitStateAutoFixSucceed');
|
||||
logProgress(i18n.t('Log.CantSyncInSpecialGitStateAutoFixSucceed'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -269,11 +269,11 @@ async function commitAndSync(wikiFolderPath, githubRepoUrl, userInfo, loggerToMa
|
|||
// preflight check
|
||||
const repoStartingState = await getGitRepositoryState(wikiFolderPath, logInfo, logProgress);
|
||||
if (!repoStartingState || repoStartingState === '|DIRTY') {
|
||||
const SYNC_MESSAGE = 'Log.PrepareSync'
|
||||
const SYNC_MESSAGE = i18n.t('Log.PrepareSync');
|
||||
logProgress(SYNC_MESSAGE);
|
||||
logInfo(`${SYNC_MESSAGE} ${wikiFolderPath} , ${username} <${email}>`)
|
||||
logInfo(`${SYNC_MESSAGE} ${wikiFolderPath} , ${username} <${email}>`);
|
||||
} else if (repoStartingState === 'NOGIT') {
|
||||
const CANT_SYNC_MESSAGE = 'Log.CantSyncGitNotInitialized';
|
||||
const CANT_SYNC_MESSAGE = i18n.t('Log.CantSyncGitNotInitialized');
|
||||
logProgress(CANT_SYNC_MESSAGE);
|
||||
throw new Error(CANT_SYNC_MESSAGE);
|
||||
} else {
|
||||
|
|
@ -282,9 +282,9 @@ async function commitAndSync(wikiFolderPath, githubRepoUrl, userInfo, loggerToMa
|
|||
}
|
||||
|
||||
if (await haveLocalChanges(wikiFolderPath)) {
|
||||
const SYNC_MESSAGE = 'Log.HaveThingsToCommit'
|
||||
const SYNC_MESSAGE = i18n.t('Log.HaveThingsToCommit');
|
||||
logProgress(SYNC_MESSAGE);
|
||||
logInfo(`${SYNC_MESSAGE} ${commitMessage}`)
|
||||
logInfo(`${SYNC_MESSAGE} ${commitMessage}`);
|
||||
const { exitCode: commitExitCode, stderr: commitStdError } = await commitFiles(
|
||||
wikiFolderPath,
|
||||
username,
|
||||
|
|
@ -295,69 +295,69 @@ async function commitAndSync(wikiFolderPath, githubRepoUrl, userInfo, loggerToMa
|
|||
logInfo('commit failed');
|
||||
logInfo(commitStdError);
|
||||
}
|
||||
logProgress('Log.CommitComplete');
|
||||
logProgress(i18n.t('Log.CommitComplete'));
|
||||
}
|
||||
logProgress('Log.PreparingUserInfo');
|
||||
logProgress(i18n.t('Log.PreparingUserInfo'));
|
||||
await credentialOn(wikiFolderPath, githubRepoUrl, userInfo);
|
||||
logProgress('Log.FetchingData');
|
||||
logProgress(i18n.t('Log.FetchingData'));
|
||||
await GitProcess.exec(['fetch', 'origin', 'master'], wikiFolderPath);
|
||||
|
||||
//
|
||||
switch (await getSyncState(wikiFolderPath, logInfo)) {
|
||||
case 'noUpstream': {
|
||||
logProgress('Log.CantSyncGitNotInitialized');
|
||||
logProgress(i18n.t('Log.CantSyncGitNotInitialized'));
|
||||
return;
|
||||
}
|
||||
case 'equal': {
|
||||
logProgress('Log.NoNeedToSync');
|
||||
logProgress(i18n.t('Log.NoNeedToSync'));
|
||||
return;
|
||||
}
|
||||
case 'ahead': {
|
||||
logProgress('Log.LocalAheadStartUpload');
|
||||
logProgress(i18n.t('Log.LocalAheadStartUpload'));
|
||||
const { exitCode, stderr } = await GitProcess.exec(['push', 'origin', branchMapping], wikiFolderPath);
|
||||
if (exitCode === 0) break;
|
||||
logProgress('Log.GitPushFailed');
|
||||
logProgress(i18n.t('Log.GitPushFailed'));
|
||||
logInfo(`exitCode: ${exitCode}, stderr of git push:`);
|
||||
logInfo(stderr);
|
||||
break;
|
||||
}
|
||||
case 'behind': {
|
||||
logProgress('Log.LocalStateBehindSync');
|
||||
logProgress(i18n.t('Log.LocalStateBehindSync'));
|
||||
const { exitCode, stderr } = await GitProcess.exec(
|
||||
['merge', '--ff', '--ff-only', 'origin/master'],
|
||||
wikiFolderPath,
|
||||
);
|
||||
if (exitCode === 0) break;
|
||||
logProgress('Log.GitMergeFailed');
|
||||
logProgress(i18n.t('Log.GitMergeFailed'));
|
||||
logInfo(`exitCode: ${exitCode}, stderr of git merge:`);
|
||||
logInfo(stderr);
|
||||
break;
|
||||
}
|
||||
case 'diverged': {
|
||||
logProgress('Log.LocalStateDivergeRebase');
|
||||
logProgress(i18n.t('Log.LocalStateDivergeRebase'));
|
||||
const { exitCode } = await GitProcess.exec(['rebase', 'origin/master'], wikiFolderPath);
|
||||
if (
|
||||
exitCode === 0 &&
|
||||
!(await getGitRepositoryState(wikiFolderPath, logInfo, logProgress)) &&
|
||||
(await getSyncState(wikiFolderPath, logInfo)) === 'ahead'
|
||||
) {
|
||||
logProgress('Log.RebaseSucceed');
|
||||
logProgress(i18n.t('Log.RebaseSucceed'));
|
||||
} else {
|
||||
await continueRebase(wikiFolderPath, username, email, logInfo, logProgress);
|
||||
logProgress('Log.RebaseConfliceNeedsResolve');
|
||||
logProgress(i18n.t('Log.RebaseConfliceNeedsResolve'));
|
||||
}
|
||||
await GitProcess.exec(['push', 'origin', branchMapping], wikiFolderPath);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
logProgress('Log.SyncFailedSystemError');
|
||||
logProgress(i18n.t('Log.SyncFailedSystemError'));
|
||||
}
|
||||
}
|
||||
|
||||
await credentialOff(wikiFolderPath);
|
||||
logProgress('Log.PerformLastCheckBeforeSynchronizationFinish');
|
||||
logProgress(i18n.t('Log.PerformLastCheckBeforeSynchronizationFinish'));
|
||||
await assumeSync(wikiFolderPath, logInfo, logProgress);
|
||||
logProgress('Log.SynchronizationFinish');
|
||||
logProgress(i18n.t('Log.SynchronizationFinish'));
|
||||
}
|
||||
|
||||
async function getRemoteUrl(wikiFolderPath) {
|
||||
|
|
@ -374,8 +374,8 @@ async function getRemoteUrl(wikiFolderPath) {
|
|||
async function clone(githubRepoUrl, repoFolderPath, userInfo) {
|
||||
const logProgress = message => logger.notice(message, { handler: 'createWikiProgress', function: 'clone' });
|
||||
const logInfo = message => logger.info(message, { function: 'clone' });
|
||||
logProgress('Log.PrepareCloneOnlineWiki');
|
||||
logProgress('Log.InitialGitInitialization');
|
||||
logProgress(i18n.t('Log.PrepareCloneOnlineWiki'));
|
||||
logProgress(i18n.t('Log.InitialGitInitialization'));
|
||||
const { login: username, accessToken } = userInfo;
|
||||
logInfo(
|
||||
`Using gitUrl ${githubRepoUrl} with username ${username} and accessToken ${truncate(accessToken, {
|
||||
|
|
@ -383,18 +383,18 @@ async function clone(githubRepoUrl, repoFolderPath, userInfo) {
|
|||
})}`,
|
||||
);
|
||||
await GitProcess.exec(['init'], repoFolderPath);
|
||||
logProgress('Log.StartConfiguringGithubRemoteRepository');
|
||||
logProgress(i18n.t('Log.StartConfiguringGithubRemoteRepository'));
|
||||
await credentialOn(repoFolderPath, githubRepoUrl, userInfo);
|
||||
logProgress('Log.StartFetchingFromGithubRemote');
|
||||
logProgress(i18n.t('Log.StartFetchingFromGithubRemote'));
|
||||
const { stderr, exitCode } = await GitProcess.exec(['pull', 'origin', 'master:master'], repoFolderPath);
|
||||
await credentialOff(repoFolderPath);
|
||||
if (exitCode !== 0) {
|
||||
logInfo(stderr);
|
||||
const CONFIG_FAILED_MESSAGE = 'Log.GitRepositoryConfigurateFailed';
|
||||
const CONFIG_FAILED_MESSAGE = i18n.t('Log.GitRepositoryConfigurateFailed');
|
||||
logProgress(CONFIG_FAILED_MESSAGE);
|
||||
throw new Error(CONFIG_FAILED_MESSAGE);
|
||||
} else {
|
||||
logProgress('Log.GitRepositoryConfigurationFinished');
|
||||
logProgress(i18n.t('Log.GitRepositoryConfigurationFinished'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
23
public/libs/i18n.js
Normal file
23
public/libs/i18n.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
const isDev = require('electron-is-dev');
|
||||
const path = require('path');
|
||||
const i18next = require('i18next');
|
||||
const Backend = require('i18next-fs-backend');
|
||||
|
||||
const { LOCALIZATION_FOLDER } = require('../constants/paths');
|
||||
|
||||
i18next.use(Backend).init({
|
||||
backend: {
|
||||
loadPath: path.join(LOCALIZATION_FOLDER, 'locales/{{lng}}/{{ns}}.json'),
|
||||
addPath: path.join(LOCALIZATION_FOLDER, 'locales/{{lng}}/{{ns}}.missing.json'),
|
||||
},
|
||||
|
||||
debug: false,
|
||||
interpolation: { escapeValue: false },
|
||||
saveMissing: isDev,
|
||||
saveMissingTo: 'current',
|
||||
namespace: 'translation',
|
||||
lng: 'zh_CN',
|
||||
fallbackLng: isDev ? false : 'en', // set to false when generating translation files locally
|
||||
});
|
||||
|
||||
module.exports = i18next;
|
||||
|
|
@ -2,6 +2,7 @@ const fs = require('fs-extra');
|
|||
const path = require('path');
|
||||
const sendToAllWindows = require('./send-to-all-windows');
|
||||
const { LOCALIZATION_FOLDER } = require('../constants/paths');
|
||||
const i18n = require('./i18n');
|
||||
|
||||
// Electron-specific; must match mainIpc
|
||||
const readFileRequest = 'ReadFile-Request';
|
||||
|
|
@ -88,6 +89,7 @@ function getLanguageMenu() {
|
|||
// eslint-disable-next-line global-require
|
||||
const { onEachView } = require('./views');
|
||||
onEachView(view => {
|
||||
i18n.changeLanguage(language);
|
||||
view.webContents.send(changeLanguageRequest, {
|
||||
lng: language,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,13 +4,14 @@ const { dialog } = require('electron');
|
|||
|
||||
const { startWiki } = require('./wiki-worker-mamager');
|
||||
const mainWindow = require('../../windows/main');
|
||||
const i18n = require('../i18n');
|
||||
|
||||
module.exports = function startNodeJSWiki(homePath, port, userName, workspaceID) {
|
||||
if (!homePath || typeof homePath !== 'string' || !path.isAbsolute(homePath)) {
|
||||
const errorMessage = '需要传入正确的路径,而此路径无法被 TiddlyWiki 识别。';
|
||||
const errorMessage = i18n.t('Dialog.NeedCorrectTiddlywikiFolderPath');
|
||||
console.error(errorMessage);
|
||||
dialog.showMessageBox(mainWindow.get(), {
|
||||
title: '传入的路径无法使用',
|
||||
title: i18n.t('Dialog.PathPassinCantUse'),
|
||||
message: errorMessage + homePath,
|
||||
buttons: ['OK'],
|
||||
cancelId: 0,
|
||||
|
|
@ -19,13 +20,13 @@ module.exports = function startNodeJSWiki(homePath, port, userName, workspaceID)
|
|||
return;
|
||||
}
|
||||
if (!fs.pathExistsSync(homePath)) {
|
||||
const errorMessage = '无法找到之前还在该处的工作区文件夹!本应存在于此处的文件夹可能被移走了!是否移除工作区?';
|
||||
const errorMessage = i18n.t('Dialog.CantFindWorkspaceFolderRemoveWorkspace');
|
||||
console.error(errorMessage);
|
||||
dialog
|
||||
.showMessageBox(mainWindow.get(), {
|
||||
title: '工作区文件夹被移走',
|
||||
title: i18n.t('Dialog.WorkspaceFolderRemoved'),
|
||||
message: errorMessage + homePath,
|
||||
buttons: ['移除工作区', '不管'],
|
||||
buttons: [i18n.t('Dialog.RemoveWorkspace'), i18n.t('Dialog.DontCare')],
|
||||
cancelId: 1,
|
||||
defaultId: 0,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ const { stopWatchWiki } = require('../libs/wiki/watch-wiki');
|
|||
const { stopWiki } = require('../libs/wiki/wiki-worker-mamager');
|
||||
const { logger } = require('../libs/log');
|
||||
const { createWiki, createSubWiki, removeWiki, ensureWikiExist, cloneWiki, cloneSubWiki } = require('../libs/wiki/create-wiki');
|
||||
const { ICON_PATH, REACT_PATH, DESKTOP_PATH, LOG_FOLDER } = require('../constants/paths');
|
||||
const { ICON_PATH, REACT_PATH, DESKTOP_PATH, LOG_FOLDER, isDev } = require('../constants/paths');
|
||||
|
||||
const { getPreference, getPreferences, resetPreferences, setPreference } = require('../libs/preferences');
|
||||
|
||||
|
|
@ -110,6 +110,7 @@ const loadListeners = () => {
|
|||
REACT_PATH,
|
||||
DESKTOP_PATH,
|
||||
LOG_FOLDER,
|
||||
isDev,
|
||||
}[name];
|
||||
});
|
||||
ipcMain.handle('request-init-wiki-git', async (event, wikiFolderPath, githubRepoUrl, userInfo, isMainWiki) => {
|
||||
|
|
|
|||
|
|
@ -80,9 +80,7 @@ function CloneWikiDoneButton({
|
|||
<>
|
||||
{progressBarOpen && <LinearProgress color="secondary" />}
|
||||
<Snackbar open={snackBarOpen} autoHideDuration={5000} onClose={() => snackBarOpenSetter(false)}>
|
||||
<Alert severity="info">
|
||||
<Trans>{wikiCreationMessage}</Trans>
|
||||
</Alert>
|
||||
<Alert severity="info">{wikiCreationMessage}</Alert>
|
||||
</Snackbar>
|
||||
|
||||
{isCreateMainWorkspace ? (
|
||||
|
|
|
|||
|
|
@ -76,9 +76,7 @@ function DoneButton({
|
|||
<>
|
||||
{progressBarOpen && <LinearProgress color="secondary" />}
|
||||
<Snackbar open={snackBarOpen} autoHideDuration={5000} onClose={() => snackBarOpenSetter(false)}>
|
||||
<Alert severity="info">
|
||||
<Trans>{wikiCreationMessage}</Trans>
|
||||
</Alert>
|
||||
<Alert severity="info">{wikiCreationMessage}</Alert>
|
||||
</Snackbar>
|
||||
|
||||
{isCreateMainWorkspace ? (
|
||||
|
|
|
|||
|
|
@ -50,11 +50,13 @@ class GitHubLogin extends Component<Props, State> {
|
|||
}
|
||||
|
||||
async isLogin() {
|
||||
const { onSuccess } = this.props;
|
||||
const { onSuccess, onLogout } = this.props;
|
||||
const { session, ...rest } = await this.auth.trackSession();
|
||||
const isLogin = session !== null;
|
||||
if (isLogin) {
|
||||
onSuccess(rest);
|
||||
} else {
|
||||
onLogout();
|
||||
}
|
||||
return isLogin;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,9 +81,7 @@ function NewWikiDoneButton({
|
|||
<>
|
||||
{progressBarOpen && <LinearProgress color="secondary" />}
|
||||
<Snackbar open={snackBarOpen} autoHideDuration={5000} onClose={() => snackBarOpenSetter(false)}>
|
||||
<Alert severity="info">
|
||||
<Trans>{wikiCreationMessage}</Trans>
|
||||
</Alert>
|
||||
<Alert severity="info">{wikiCreationMessage}</Alert>
|
||||
</Snackbar>
|
||||
|
||||
{isCreateMainWorkspace ? (
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
import i18n from 'i18next';
|
||||
import { initReactI18next } from 'react-i18next';
|
||||
import electronFsBackend from './helpers/i18next-electron-fs-backend';
|
||||
import { getIsDevelopment } from './senders';
|
||||
|
||||
const isDev = getIsDevelopment();
|
||||
i18n
|
||||
.use(electronFsBackend)
|
||||
.use(initReactI18next)
|
||||
|
|
@ -12,13 +14,13 @@ i18n
|
|||
ipcRenderer: window.i18n.i18nextElectronBackend,
|
||||
},
|
||||
|
||||
debug: true,
|
||||
debug: isDev,
|
||||
interpolation: { escapeValue: false },
|
||||
saveMissing: true,
|
||||
saveMissing: isDev,
|
||||
saveMissingTo: 'current',
|
||||
namespace: 'translation',
|
||||
lng: 'zh_CN',
|
||||
fallbackLng: false, // set to false when generating translation files locally
|
||||
fallbackLng: isDev ? false : 'en', // set to false when generating translation files locally
|
||||
});
|
||||
|
||||
window.i18n.i18nextElectronBackend.onLanguageChange(arguments_ => {
|
||||
|
|
|
|||
|
|
@ -127,6 +127,7 @@ export const getIconPath = () => ipcRenderer.sendSync('get-constant', 'ICON_PATH
|
|||
export const getReactPath = () => ipcRenderer.sendSync('get-constant', 'REACT_PATH');
|
||||
export const getDesktopPath = () => ipcRenderer.sendSync('get-constant', 'DESKTOP_PATH');
|
||||
export const getLogFolderPath = () => ipcRenderer.sendSync('get-constant', 'LOG_FOLDER');
|
||||
export const getIsDevelopment = () => ipcRenderer.sendSync('get-constant', 'isDev');
|
||||
|
||||
// Workspace Meta
|
||||
export const getWorkspaceMeta = (id: string) => ipcRenderer.sendSync('get-workspace-meta', id);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue