Skip to content

Instantly share code, notes, and snippets.

@JWPapi
Created January 27, 2022 21:25
Show Gist options
  • Save JWPapi/cc099ec49a3b7fe94939f855aaa1ec4e to your computer and use it in GitHub Desktop.
Save JWPapi/cc099ec49a3b7fe94939f855aaa1ec4e to your computer and use it in GitHub Desktop.
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