mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
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:
19
packages/frontend/editor-ui/vite/i18n-locales-hmr-helpers.ts
Normal file
19
packages/frontend/editor-ui/vite/i18n-locales-hmr-helpers.ts
Normal 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 },
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user