mirror of
https://github.com/photoprism/photoprism.git
synced 2025-09-26 21:01:58 +08:00
Frontend: Reformat gettext.config.js with eslint
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
@@ -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,
|
||||
},
|
||||
|
Reference in New Issue
Block a user