Your IP : 3.17.176.234


Current Path : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/ui/buttons/test/
Upload File :
Current File : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/ui/buttons/test/load-messages.js

import { Loc } from 'main.core';

const fs = require('fs');
const path = require('path');

export default function loadMessages(lang = 'en')
{
	const langFile = path.join(path.normalize(__dirname + '../../lang/'), lang, 'config.php');
	const contents = fs.readFileSync(langFile, 'ascii');

	const regex = /\$MESS\[['"](?<code>.+?)['"]]\s*=\s*['"](?<phrase>.*?)['"]/gm;
	let match;

	while ((match = regex.exec(contents)) !== null)
	{
		if (match.index === regex.lastIndex)
		{
			regex.lastIndex++;
		}

		const { code, phrase } = match.groups;
		Loc.setMessage(code, phrase);
	}
}