Frontend: Disable msgmerge fuzzy matching with vue3-gettext

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2025-10-22 09:51:13 +02:00
parent 504d92efaa
commit f9a2e54476
3 changed files with 8 additions and 3 deletions

View File

@@ -74,6 +74,7 @@ testcafe:
acceptance-local:
npm run acceptance-local
gettext-extract:
# Script sets GETTEXT_MERGE=0 by default so vue-gettext skips msgmerge; scripts/gettext-merge.sh handles merging.
npm run gettext-extract
gettext-compile:
npm run gettext-compile

View File

@@ -31,6 +31,10 @@ const languageCodes = glob.sync(path.join(localesPath, "*.po")).map((filePath) =
return fileName.replace(".po", "");
});
// vue3-gettext merges msgstr entries via msgmerge; disable this when GETTEXT_MERGE=0|false.
const mergeEnv = (process.env.GETTEXT_MERGE || "").toLowerCase();
const shouldMergeLocales = mergeEnv !== "0" && mergeEnv !== "false";
// Generates one JSON file per locale from the gettext *.po files located in src/locales.
module.exports = {
input: {
@@ -42,7 +46,7 @@ module.exports = {
path: localesPath,
potPath: "translations.pot",
jsonPath: "json",
locales: languageCodes,
locales: shouldMergeLocales ? languageCodes : [],
splitJson: true,
flat: true,
linguas: false,

View File

@@ -14,8 +14,8 @@
"dep-list": "npx npm-check-updates",
"fmt": "eslint --cache --fix src/ *.js eslint.config.mjs",
"fmt-npm": "prettier --write package.json",
"gettext-compile": "vue-gettext-compile",
"gettext-extract": "vue-gettext-extract --config gettext.config.js",
"gettext-compile": "cross-env GETTEXT_MERGE=1 vue-gettext-compile --config gettext.config.js",
"gettext-extract": "cross-env GETTEXT_MERGE=0 vue-gettext-extract --config gettext.config.js",
"lint": "eslint --cache src/ *.js",
"test": "cross-env TZ=UTC BUILD_ENV=development NODE_ENV=development BABEL_ENV=test vitest run",
"test-watch": "cross-env TZ=UTC BUILD_ENV=development NODE_ENV=development BABEL_ENV=test vitest --watch",