summaryrefslogtreecommitdiff
path: root/webpack/i18n.ts
blob: 4fd439d1d585b54bd214cd91275e40e925431b27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/**
 * Replace i18n texts
 */

export const pattern = /%i18n:([a-z0-9_\-@\.]+?)%/g;

export const replacement = (ctx: any, _: any, key: string) => {
	const client = '/src/client/app/';
	let name = null;

	if (key.startsWith('@')) {
		name = ctx.src.substr(ctx.src.indexOf(client) + client.length);
		key = key.substr(1);
	}

	const path = name ? `${name}|${key}` : key;

	return `%i18n:${path}%`;
};