photoprism/frontend/gettext.config.js
Michael Mayer 0ddc179737 UX: Reduce JS bundle size by loading translation files on demand #4778
Signed-off-by: Michael Mayer <michael@photoprism.app>
2025-03-24 12:43:08 +01:00

21 lines
659 B
JavaScript

const glob = require("glob");
const path = require("path");
const poPath = path.resolve(__dirname, "src/locales");
// Generates a list of existing locales based on the files in src/locales.
const languageCodes = glob.sync(poPath + "/*.po").map((filePath) => {
const fileName = path.basename(filePath);
return fileName.replace(".po", "");
});
// Generates one JSON file per locale from the gettext *.po files located in src/locales.
module.exports = {
output: {
path: path.resolve(__dirname, "src/locales"),
potPath: "src/locales/translations.pot",
jsonPath: "json",
locales: languageCodes,
splitJson: true,
flat: true,
},
};