Frontend: Reformat gettext.config.js with eslint

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2025-03-24 09:26:51 +01:00
parent fb65bb7935
commit dd3c80bd62

View File

@@ -1,42 +1,42 @@
const glob = require('glob'); const glob = require("glob");
const fs = require('fs'); const fs = require("fs");
const path = require('path'); const path = require("path");
// Find all .po files in the frontend/src/locales // Find all .po files in the frontend/src/locales
const poFiles = glob.sync('src/locales/*.po'); const poFiles = glob.sync("src/locales/*.po");
if (poFiles.length === 0) { if (poFiles.length === 0) {
console.error('No .po files found in src/locales'); console.error("No .po files found in src/locales");
process.exit(1); process.exit(1);
} }
// Find output folder or create the new one in assets/static/locales // Find output folder or create the new one in assets/static/locales
const outputDir = path.resolve(__dirname, '../assets/static/locales'); const outputDir = path.resolve(__dirname, "../assets/static/locales");
if (!fs.existsSync(outputDir)) { if (!fs.existsSync(outputDir)) {
fs.mkdirSync(outputDir, { recursive: true }); fs.mkdirSync(outputDir, { recursive: true });
} }
// Copy .po files from frontend/src/locales to assets/static/locales // Copy .po files from frontend/src/locales to assets/static/locales
poFiles.forEach(filePath => { poFiles.forEach((filePath) => {
const fileName = path.basename(filePath); const fileName = path.basename(filePath);
const destinationPath = path.join(outputDir, fileName); const destinationPath = path.join(outputDir, fileName);
fs.copyFileSync(filePath, destinationPath); fs.copyFileSync(filePath, destinationPath);
}); });
// Find all languages codes from .po files (cut file names without .po) // Find all languages codes from .po files (cut file names without .po)
const languageCodes = poFiles.map(filePath => { const languageCodes = poFiles.map((filePath) => {
const fileName = path.basename(filePath); const fileName = path.basename(filePath);
return fileName.replace('.po', ''); return fileName.replace(".po", "");
}); });
// Transform files from .po to .json in the assets/static/locales // Transform files from .po to .json in the assets/static/locales
module.exports = { module.exports = {
input: { input: {
path: path.resolve(__dirname, '../assets/static/locales'), path: path.resolve(__dirname, "../assets/static/locales"),
include: ['**/*.po'], include: ["**/*.po"],
}, },
output: { output: {
path: path.resolve(__dirname, '../assets/static/locales'), path: path.resolve(__dirname, "../assets/static/locales"),
jsonPath: '', jsonPath: "",
locales: languageCodes, locales: languageCodes,
splitJson: true, splitJson: true,
}, },