fix(editor): Fix i18n package locale files hot reloading (no-changelog) (#19385)

Co-authored-by: Csaba Tuncsik <csaba.tuncsik@gmail.com>
This commit is contained in:
Alex Grozav
2025-09-15 10:18:19 +01:00
committed by GitHub
parent 9aeb000453
commit f9e78ea9bc
15 changed files with 585 additions and 57 deletions

View File

@@ -0,0 +1,19 @@
import { sep as pathSep } from 'path';
export const isLocaleFile = (file: string): boolean =>
file.endsWith('.json') && file.includes(`${pathSep}locales${pathSep}`);
export const extractLocale = (file: string): string | null => {
const match = file.match(new RegExp(`${pathSep}locales${pathSep}([^${pathSep}]+)\\.json$`));
return match?.[1] ?? null;
};
export const sendLocaleUpdate = (server: any, file: string): void => {
if (!isLocaleFile(file)) return;
const locale = extractLocale(file);
server.ws.send({
type: 'custom',
event: 'n8n:locale-update',
data: { locales: locale ? [locale] : [], file },
});
};