Created
January 27, 2022 18:14
-
-
Save JWPapi/5c4691eb37abb75910ff0c517ce55597 to your computer and use it in GitHub Desktop.
version 2
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_UY','es_VE','gl_ES'], | |
['pt_BR','pt_PT'], | |
['zh_CN','zh_TW','zh_HK'] | |
] | |
const copyTranslation = (inputCountryCode, outputCountryCode, file) => fs.copyFileSync(file, file.replace(inputCountryCode, outputCountryCode, fs.constants.COPYFILE_EXCL)) | |
const copyTranslationForGroup = (file, translationsGroup, inputCountryCode) => translationsGroup.forEach(translation => copyTranslation(inputCountryCode, 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