From 2e8adde7b7d805c09d2d1defdb09c13e5d43dfa4 Mon Sep 17 00:00:00 2001 From: Leo Zurbriggen Date: Thu, 8 Aug 2024 19:27:51 +0200 Subject: [PATCH] #56: Add `fuzzyMatching` output option to allow disabling to pass `--no-fuzzy-matching` to msgmerge --- docs/extraction.md | 1 + scripts/config.ts | 1 + scripts/gettext_extract.ts | 6 +++++- src/typeDefs.ts | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/extraction.md b/docs/extraction.md index 4f2247d..05f697b 100644 --- a/docs/extraction.md +++ b/docs/extraction.md @@ -69,6 +69,7 @@ module.exports = { flat: true, // create a subdirectory for each locale linguas: true, // create a LINGUAS file splitJson: false, // create separate json files for each locale. If used, jsonPath must end with a directory, not a file + fuzzyMatching: true, // set if fuzzy matching should be enabled when merging the pot file into the po files }, }; ``` diff --git a/scripts/config.ts b/scripts/config.ts index 822be31..9330fc5 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -48,6 +48,7 @@ export const loadConfig = async (cliArgs?: { config?: string }): Promise { mkdirSync(poDir, { recursive: true }); const isFile = existsSync(poFile) && lstatSync(poFile).isFile(); if (isFile) { - await execShellCommand(`msgmerge --lang=${loc} --update ${poFile} ${config.output.potPath} --backup=off`); + await execShellCommand( + `msgmerge --lang=${loc} --update ${poFile} ${config.output.potPath} ${ + config.output.fuzzyMatching ? "" : "--no-fuzzy-matching" + } --backup=off`, + ); console.info(`${chalk.green("Merged")}: ${chalk.blueBright(poFile)}`); } else { // https://www.gnu.org/software/gettext/manual/html_node/msginit-Invocation.html diff --git a/src/typeDefs.ts b/src/typeDefs.ts index ea4194f..97816b0 100644 --- a/src/typeDefs.ts +++ b/src/typeDefs.ts @@ -123,6 +123,7 @@ export interface GettextConfig { flat: boolean; linguas: boolean; splitJson: boolean; + fuzzyMatching: boolean; }; }