Skip to content

Instantly share code, notes, and snippets.

@JWPapi
Created January 27, 2022 18:14
Show Gist options
  • Save JWPapi/5c4691eb37abb75910ff0c517ce55597 to your computer and use it in GitHub Desktop.
Save JWPapi/5c4691eb37abb75910ff0c517ce55597 to your computer and use it in GitHub Desktop.
version 2
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