1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-21 09:38:01 +02:00

Tools: Fixed issue with gettext not knowing how to parse regex that includes backtick

This commit is contained in:
Laurent Cozic 2020-12-05 11:54:58 +00:00
parent 42232fac84
commit 046433a947
6 changed files with 19 additions and 3 deletions

View File

@ -961,6 +961,9 @@ packages/lib/services/ExternalEditWatcher.js.map
packages/lib/services/KeymapService.d.ts
packages/lib/services/KeymapService.js
packages/lib/services/KeymapService.js.map
packages/lib/services/KeymapService_keysRegExp.d.ts
packages/lib/services/KeymapService_keysRegExp.js
packages/lib/services/KeymapService_keysRegExp.js.map
packages/lib/services/KvStore.d.ts
packages/lib/services/KvStore.js
packages/lib/services/KvStore.js.map

3
.gitignore vendored
View File

@ -950,6 +950,9 @@ packages/lib/services/ExternalEditWatcher.js.map
packages/lib/services/KeymapService.d.ts
packages/lib/services/KeymapService.js
packages/lib/services/KeymapService.js.map
packages/lib/services/KeymapService_keysRegExp.d.ts
packages/lib/services/KeymapService_keysRegExp.js
packages/lib/services/KeymapService_keysRegExp.js.map
packages/lib/services/KvStore.d.ts
packages/lib/services/KvStore.js
packages/lib/services/KvStore.js.map

View File

@ -17,6 +17,7 @@
"buildDoc": "./packages/tools/build-all.sh",
"buildPluginDoc": "typedoc --name 'Joplin Plugin API Documentation' --mode file -theme './Assets/PluginDocTheme/' --readme './Assets/PluginDocTheme/index.md' --excludeNotExported --excludeExternals --excludePrivate --excludeProtected --out docs/api/references/plugin_api packages/lib/services/plugins/api/",
"buildTranslations": "npm run tsc && node packages/tools/build-translation.js",
"buildTranslationsNoTsc": "node packages/tools/build-translation.js",
"buildWebsite": "npm run buildApiDoc && node ./packages/tools/build-website.js && npm run buildPluginDoc",
"clean": "lerna clean -y && lerna run clean",
"generateDatabaseTypes": "node packages/tools/generate-database-types",

View File

@ -1,10 +1,10 @@
import eventManager from '../eventManager';
import shim from '../shim';
import { _ } from '../locale';
import keysRegExp from './KeymapService_keysRegExp';
const BaseService = require('./BaseService').default;
const keysRegExp = /^([0-9A-Z)!@#$%^&*(:+<_>?~{|}";=,\-./`[\\\]']|F1*[1-9]|F10|F2[0-4]|Plus|Space|Tab|Backspace|Delete|Insert|Return|Enter|Up|Down|Left|Right|Home|End|PageUp|PageDown|Escape|Esc|VolumeUp|VolumeDown|VolumeMute|MediaNextTrack|MediaPreviousTrack|MediaStop|MediaPlayPause|PrintScreen|Numlock|Scrolllock|Capslock|num([0-9]|dec|add|sub|mult|div))$/;
const modifiersRegExp = {
darwin: /^(Ctrl|Option|Shift|Cmd)$/,
default: /^(Ctrl|Alt|AltGr|Shift|Super)$/,

View File

@ -0,0 +1,9 @@
// We move this regex outside KeymapService because it makes gettext parsing
// fail. In fact it doesn't fail at the regex itself but at the next backtick
// into the code. Probably their parser see a backtick in the regex and opens a
// JS template string, while it shouldn't.
// https://discourse.joplinapp.org/t/translations/12832?u=laurent
const keysRegExp = /^([0-9A-Z)!@#$%^&*(:+<_>?~{|}";=,\-./`[\\\]']|F1*[1-9]|F10|F2[0-4]|Plus|Space|Tab|Backspace|Delete|Insert|Return|Enter|Up|Down|Left|Right|Home|End|PageUp|PageDown|Escape|Esc|VolumeUp|VolumeDown|VolumeMute|MediaNextTrack|MediaPreviousTrack|MediaStop|MediaPlayPause|PrintScreen|Numlock|Scrolllock|Capslock|num([0-9]|dec|add|sub|mult|div))$/;
export default keysRegExp;

View File

@ -130,7 +130,7 @@ async function createPotFile(potFilePath) {
if (isMac()) xgettextPath = executablePath('xgettext'); // Needs to have been installed with `brew install gettext`
const cmd = `${xgettextPath} ${args.join(' ')}`;
const result = await execCommand(cmd);
if (result) console.error(result);
if (result && result.trim()) console.error(result.trim());
await removePoHeaderDate(potFilePath);
}
@ -140,7 +140,7 @@ async function mergePotToPo(potFilePath, poFilePath) {
const command = `${msgmergePath} -U "${poFilePath}" "${potFilePath}"`;
const result = await execCommand(command);
if (result) console.error(result);
if (result && result.trim()) console.info(result.trim());
await removePoHeaderDate(poFilePath);
}