Files
SHiNE-server/shine-UI/tests/i18n-source-helper.mjs
T

11 lines
412 B
JavaScript

import { readFileSync } from 'node:fs';
const russian = JSON.parse(readFileSync(new URL('../js/i18n/locales/ru.json', import.meta.url), 'utf8'));
export function expandRussian(source) {
return source.replace(/t\('([a-z0-9_.]+)'\)/gu, (call, key) => {
const value = key.split('.').reduce((node, part) => node?.[part], russian);
return typeof value === 'string' ? JSON.stringify(value) : call;
});
}