Created
January 27, 2022 21:25
-
-
Save JWPapi/cc099ec49a3b7fe94939f855aaa1ec4e 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
const fs = require('fs') | |
const translationsGroups = [ | |
['fr_FR','fr_CA'], | |
['es_ES','es_MX','es_CL','es_CO','eu_ES','es_VE','gl_ES'], | |
['pt_BR','pt_PT'], | |
['zh_CN','zh_TW','zh_HK'] | |
] | |
const copyTranslation = (inCountryCode, outCountryCode, file) => fs.copyFileSync(file, file.replace(inCountryCode, outCountryCode, fs.constants.COPYFILE_EXCL)) | |
const copyTranslationForGroup = (file, translationsGroup, inCountryCode) => translationsGroup.forEach(translation => copyTranslation(inCountryCode, translation, file)) | |
fs.readdir(__dirname, (err, files) => { | |
if (err) throw err | |
files.forEach(file => { | |
translationsGroups.forEach((translationGroup) => { | |
translationGroup.forEach((translation) => { | |
if (file.includes(translation)) copyTranslationForGroup(file, translationGroup, translation) | |
}) | |
}) | |
}) | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment