Created
February 22, 2019 13:56
-
-
Save jacob-jonkman/2d5d26df672376bc31cd08710708a96b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as fs from 'fs'; | |
const languages = ['eng', 'fra', 'nl']; | |
const regex = /(\<x(\s+([^\/]*))\/\>)/gi; | |
languages.forEach(lang => { | |
const data: string = fs.readFileSync(`../../src/i18n/messages.${lang}.xlf`, 'utf-8'); | |
const dataLines: string[] = data.split('\n'); | |
const rewrittenData = dataLines.map((line: string) => { | |
return line.replace(regex, '<x$2/>'); | |
}); | |
fs.writeFileSync(`../../src/i18n/messages.${lang}.xlf`, rewrittenData.join('\n')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment