feat: add full Zonemaster stack with Docker and Spanish UI
- Clone all 5 Zonemaster component repos (LDNS, Engine, CLI, Backend, GUI) - Dockerfile.backend: 8-stage multi-stage build LDNS→Engine→CLI→Backend - Dockerfile.gui: Astro static build served via nginx - docker-compose.yml: backend (internal) + frontend (port 5353) - nginx.conf: root redirects to /es/, /api/ proxied to backend - zonemaster-gui/config.ts: defaultLanguage set to 'es' (Spanish) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
69
zonemaster-gui/scripts/messages-plugin.ts
Normal file
69
zonemaster-gui/scripts/messages-plugin.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
import path from 'path';
|
||||
import { generateMessages } from './generate-messages.ts';
|
||||
|
||||
interface MessagesPluginConfig {
|
||||
defaultLanguage: string;
|
||||
enabledLanguages: string[];
|
||||
}
|
||||
|
||||
function validateConfig(config: any): asserts config is MessagesPluginConfig {
|
||||
const errors = [];
|
||||
if (!config?.defaultLanguage) errors.push('defaultLanguage is required');
|
||||
if (!Array.isArray(config?.enabledLanguages) || !config.enabledLanguages.length)
|
||||
errors.push('enabledLanguages must be a non-empty array');
|
||||
if (config?.enabledLanguages?.some((l: any) => typeof l !== 'string'))
|
||||
errors.push('enabledLanguages must contain only strings');
|
||||
|
||||
if (errors.length) throw new Error(`messagesPlugin: ${errors.join(', ')}`);
|
||||
}
|
||||
|
||||
export function messagesIntegration() {
|
||||
return {
|
||||
name: 'messages-integration',
|
||||
hooks: {
|
||||
'astro:config:setup': ({ injectScript }: any) => {
|
||||
injectScript(
|
||||
'before-hydration',
|
||||
`
|
||||
import { setLocale } from '@/messages';
|
||||
setLocale(document.documentElement.lang);
|
||||
`
|
||||
);
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export default function messagesPlugin(config: MessagesPluginConfig) {
|
||||
validateConfig(config);
|
||||
|
||||
const langDir = path.resolve(process.cwd(), 'messages');
|
||||
const outDir = path.resolve(process.cwd(), 'src/messages');
|
||||
|
||||
const regenerate = () => {
|
||||
console.log('🔄 Generating message files...');
|
||||
generateMessages(langDir, outDir, config);
|
||||
};
|
||||
|
||||
return {
|
||||
name: 'vite-plugin-messages',
|
||||
|
||||
buildStart() {
|
||||
regenerate();
|
||||
},
|
||||
|
||||
configureServer(server: any) {
|
||||
server.watcher.add(langDir);
|
||||
},
|
||||
|
||||
handleHotUpdate({ file, server }: { file: string; server: any }) {
|
||||
if (file.startsWith(langDir) && file.endsWith('.json')) {
|
||||
console.log('♻️ Language file changed:', path.basename(file));
|
||||
regenerate();
|
||||
// Trigger a full reload to pick up the new messages
|
||||
server.ws.send({ type: 'full-reload' });
|
||||
return [];
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user