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 fs = require('fs');
const path = require('path');
const glob = require("glob");
const fs = require("fs");
const path = require("path");
// 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) {
console.error('No .po files found in src/locales');
console.error("No .po files found in src/locales");
process.exit(1);
}
// 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)) {
fs.mkdirSync(outputDir, { recursive: true });
}
// Copy .po files from frontend/src/locales to assets/static/locales
poFiles.forEach(filePath => {
poFiles.forEach((filePath) => {
const fileName = path.basename(filePath);
const destinationPath = path.join(outputDir, fileName);
fs.copyFileSync(filePath, destinationPath);
});
// 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);
return fileName.replace('.po', '');
return fileName.replace(".po", "");
});
// Transform files from .po to .json in the assets/static/locales
module.exports = {
input: {
path: path.resolve(__dirname, '../assets/static/locales'),
include: ['**/*.po'],
path: path.resolve(__dirname, "../assets/static/locales"),
include: ["**/*.po"],
},
output: {
path: path.resolve(__dirname, '../assets/static/locales'),
jsonPath: '',
path: path.resolve(__dirname, "../assets/static/locales"),
jsonPath: "",
locales: languageCodes,
splitJson: true,
},