Skip to content

Commit

Permalink
#56: Add fuzzyMatching output option to allow disabling to pass `--…
Browse files Browse the repository at this point in the history
…no-fuzzy-matching` to msgmerge
  • Loading branch information
Leo Zurbriggen committed Aug 8, 2024
1 parent 3ef8952 commit 2e8adde
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/extraction.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
};
```
Expand Down
1 change: 1 addition & 0 deletions scripts/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const loadConfig = async (cliArgs?: { config?: string }): Promise<Gettext
flat: config.output?.flat === undefined ? true : config.output.flat,
linguas: config.output?.linguas === undefined ? true : config.output.linguas,
splitJson: config.output?.splitJson === undefined ? false : config.output.splitJson,
fuzzyMatching: config.output?.fuzzyMatching === undefined ? true : config.output.fuzzyMatching,
},
};
};
6 changes: 5 additions & 1 deletion scripts/gettext_extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ var getFiles = async (config: GettextConfig) => {
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
Expand Down
1 change: 1 addition & 0 deletions src/typeDefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export interface GettextConfig {
flat: boolean;
linguas: boolean;
splitJson: boolean;
fuzzyMatching: boolean;
};
}

Expand Down

0 comments on commit 2e8adde

Please sign in to comment.