@owja/i18n
Version:
lightweight internationalization library for javascript
20 lines (16 loc) • 463 B
text/typescript
interface Value {
match: string;
arguments: string[];
}
export function Parser(translated: string, find: string): Value[] {
const search = new RegExp("(\\[\\[(" + find + ")(\\|(.*?))?\\]\\])", "gm");
const values: Value[] = [];
let m;
while ((m = search.exec(translated)) !== null) {
values.push({
match: m[0],
arguments: m[4] !== undefined ? m[4].split("|") : [],
});
}
return values;
}