Skip to content

Commit 144df89

Browse files
committed
Clean localization data files before pulling from Transifex
The localization of the UI strings specific to the Arduino IDE application is done via the Transifex localization platform. A scheduled workflow pulls the data from Transifex weekly and submits a pull request for the updates. Previously, the script used to pull the data did not clean the data files before pulling. This meant that a vestigial file would accumulate in the repository whenever a language was removed from the Transifex project. The accumulation is avoided by deleting the data files for the locales managed on Transifex (all locales other than the source English locale) before downloading the data from Transifex.
1 parent e17472e commit 144df89

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Diff for: scripts/i18n/transifex-pull.js

+11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// @ts-check
22

33
const transifex = require('./transifex');
4+
const path = require('path');
5+
const fs = require('node:fs/promises');
46
const util = require('util');
57
const shell = require('shelljs');
68
const fetch = require('node-fetch');
@@ -106,6 +108,15 @@ const getTranslationDownloadStatus = async (language, downloadRequestId) => {
106108
const languages = await getLanguages(organization, project);
107109
shell.echo('translations found:', languages.join(', '));
108110

111+
// Remove data managed on Transifex to avoid accumulation of vestigial files
112+
const translationFilenames = await fs.readdir(translationsDirectory);
113+
for (const filename of translationFilenames) {
114+
if (filename === 'en.json' || !filename.endsWith('.json')) {
115+
continue;
116+
}
117+
await fs.unlink(path.join(translationsDirectory, filename));
118+
}
119+
109120
let downloadIds = [];
110121
for (const language of languages) {
111122
downloadIds.push({

0 commit comments

Comments
 (0)