Skip to content

Commit

Permalink
Add script to check if there are phrases that are not being used
Browse files Browse the repository at this point in the history
  • Loading branch information
alexemanuelol committed Oct 10, 2023
1 parent f395b44 commit 3e390ae
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 17 deletions.
17 changes: 0 additions & 17 deletions src/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,16 @@
"abandonedCabins": "Abandoned Cabins",
"abandonedMilitaryBase": "Abandoned Military Base",
"abandonedSupermarket": "Abandoned Supermarket",
"active": "Active",
"activeCap": "ACTIVE",
"addPlayerCap": "ADD PLAYER",
"addSwitchCap": "ADD SWITCH",
"afkCap": "AFK",
"airfield": "Airfield",
"alarmHaveNotBeenTriggeredYet": "The alarm {alarm} have not been triggered yet.",
"all": "all",
"allOfflineCap": "ALL OFFLINE",
"allTeammatesAreDead": "All your teammates are dead.",
"alreadySubscribedToItem": "Already subscribed to item {name}.",
"ampersand": "Ampersand",
"and": "and",
"andMorePlayers": "... and {number} more players.",
"anyOnlineCap": "ANY ONLINE",
"apostrophe": "Apostrophe",
"arcticResearchBase": "Arctic Research Base",
"asterisk": "Asterisk",
Expand Down Expand Up @@ -46,7 +41,6 @@
"boomBox": "Boom Box",
"bot": "bot",
"broadcaster": "Broadcaster",
"buttonReconnecting": "RECONNECTING",
"buttonValueChange": "Button Interaction - VerifyId: {id}, Value: {value}.",
"buy": "buy",
"cargoAt": "At {location}.",
Expand Down Expand Up @@ -143,7 +137,6 @@
"commandSyntaxUptime": "uptime",
"commandSyntaxWipe": "wipe",
"commandSyntaxWood": "wood",
"commandUnavailable": "Command is unavailable when host is offline and dead.",
"commandsAlarmDesc": "Operations on Smart Alarms.",
"commandsAlarmEditDesc": "Edit the properties of a Smart Alarm.",
"commandsAlarmEditIdDesc": "The ID of the Smart Alarm.",
Expand Down Expand Up @@ -223,7 +216,6 @@
"commandsVoiceMale": "Male",
"commandsVoiceMaleDescription": "Sets the voiceactor gender to Male",
"commandsVoiceNotInVoice": "You are not in a voicechannel",
"commandsVoiceSettingsDesc": "Changes the Bot's voice settings.",
"connect": "Connect",
"connectCap": "CONNECT",
"connectedCap": "CONNECTED",
Expand All @@ -232,7 +224,6 @@
"connectingToServer": "CONNECTING TO SERVER...",
"connectionRefusedTo": "Connection refused to: {id}.",
"connectionsCap": "CONNECTIONS",
"container": "Container",
"couldNotAddStepTracers": "Could not add step tracers.",
"couldNotAppendMapMarkers": "Could not append map markers, rustplus info instance is not set.",
"couldNotAppendMapMonuments": "Could not append map monuments, rustplus info instance is not set.",
Expand Down Expand Up @@ -316,9 +307,6 @@
"eventCap": "EVENT",
"eventInfo": "Event Information",
"exclamationMark": "Exclamation Mark",
"failedToGetServerInfo": "Failed to get server info via battlemetrics for serverId: {id}.",
"failedToGetTeamTrackerInfo": "Failed to get server team tracker info via battlemetrics for serverId: {id}.",
"failedToScrape": "Failed to scrape: {scrape}.",
"failedToScrapeProfileName": "Failed to scrape profile name: {link}.",
"failedToScrapeProfilePicture": "Failed to scrape profile picture: {link}.",
"fcmCredentials": "FCM Credentials",
Expand Down Expand Up @@ -353,7 +341,6 @@
"inGameEventInfo": "In-game event information",
"inGameTeamNotificationsSetting": "In-Game teammate notifications.",
"inGameTime": "In-Game time: {time}.",
"inactiveCap": "INACTIVE",
"infoCap": "INFO",
"interactionEditReplyFailed": "Interaction edit reply failed: {error}",
"interactionInvalidChannel": "Interaction from an invalid channel.",
Expand Down Expand Up @@ -606,22 +593,19 @@
"switches": "Switches",
"teamMember": "Team Member",
"teamMemberInfo": "Team Member Information",
"test": "This is a test",
"theDome": "The Dome",
"three": "Three",
"tilde": "Tilde",
"time": "Time",
"timeBeforeCargoEntersEgress": "{time} before Cargo Ship at {location} enters egress stage.",
"timeBeforeCrateAtLargeOilRigUnlocks": "{time} before Locked Crate at Large Oil Rig ({location}) unlocks.",
"timeBeforeCrateAtSmallOilRigUnlocks": "{time} before Locked Crate at Small Oil Rig ({location}) unlocks.",
"timeBeforeRespawn": "{time} before respawn.",
"timeCap": "TIME",
"timeFormatInvalid": "Time format invalid.",
"timeLeftTimer": "{id}: Time left: {time}, Message: {message}",
"timeSinceAlarmWasTriggered": "The alarm {alarm} was triggered {time} ago.",
"timeSinceCargoLeft": "{time} since Cargo Ship left the map.",
"timeSinceChinook47OnMap": "{time} since the last Chinook 47 was on the map.",
"timeSinceDestroyed": "{time} since destroyed.",
"timeSinceHeavyScientistsOnLarge": "{time} since Heavy Scientists last got called to Large Oil Rig.",
"timeSinceHeavyScientistsOnSmall": "{time} since Heavy Scientists last got called to Small Oil Rig.",
"timeSinceLast": "{time} since last.",
Expand Down Expand Up @@ -684,7 +668,6 @@
"websiteCap": "WEBSITE",
"websocketClosedBeforeConnection": "WebSocket was closed before the connection was established.",
"westOfGrid": "West of grid",
"whenTrackersNotifySetting": "When should the Battlemetrics trackers notify?",
"wipe": "Wipe",
"wipeDetected": "Wipe detected!",
"youAreAlreadyLeader": "You are already leader.",
Expand Down
76 changes: 76 additions & 0 deletions src/util/external/findUnusedPhrases.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
Copyright (C) 2023 Alexander Emanuelsson (alexemanuelol)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
https://github.com/alexemanuelol/rustplusplus
*/

const Path = require('path');
const Fs = require('fs');

const root = Path.join(__dirname, '../..');
const enJsonPath = Path.join(root, 'languages/en.json');
const allFiles = [];

const ignoredDirs = [
'languages',
'resources',
'docs'
];

function recursiveSearchOfAllFiles(path) {
Fs.readdirSync(path).forEach(file => {
const filePath = Path.join(path, file);

if (Fs.lstatSync(filePath).isDirectory()) {
if (!ignoredDirs.includes(file)) {
recursiveSearchOfAllFiles(filePath);
}
}
else {
allFiles.push(filePath);
}
})
}
recursiveSearchOfAllFiles(root);

const phrases = JSON.parse(Fs.readFileSync(enJsonPath, 'utf8'));
const phrasesKeys = Object.keys(phrases);
const nbrOfPhrases = phrasesKeys.length;

let counter = 1;
const unusedPhrases = [];
for (const phrase of phrasesKeys) {
console.log(`Phrase (${counter}/${nbrOfPhrases})`);

let used = false;
for (const file of allFiles) {
const data = Fs.readFileSync(file, { encoding: 'utf8', flag: 'r' });
if (data.includes(`'${phrase}'`) || data.includes(`"${phrase}"`) || data.includes(`\`${phrase}\``)) {
used = true;
break;
}
}

if (!used) {
unusedPhrases.push(phrase);
}

counter += 1;
}

console.log('\nUnused Phrases:\n');
console.log(unusedPhrases);

0 comments on commit 3e390ae

Please sign in to comment.