element-web-patches/patches/rename_remove_and_ban.sh

77 lines
4.0 KiB
Bash
Executable File

#!/bin/sh
# This file is part of the element-web-patches.
#
# element-web-patches 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.
#
# element-web-patches 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 element-web-patches. If not, see <https://www.gnu.org/licenses/>.
echo "Renaming remove & ban..."
# Modify these to your liking
remove_command="holocaust"
remove_command_plural="holocausts"
remove_command_past_tense="holocausted"
capital_remove_command="Holocaust"
capital_remove_command_plural="Holocausts"
capital_remove_command_past_tense="Holocausted"
ban_command="gas"
ban_command_plural="gasses"
ban_command_past_tense="gassed"
capital_ban_command="Gas"
capital_ban_command_plural="Gasses"
capital_ban_command_past_tense="Gassed"
error() {
echo "Failed to rename, exiting..."
exit 1
}
# Remove
sed -i -e "s/remove/${remove_command}/g" \
-e "s/Removes/${capital_remove_command_plural}/g" "${1}"/node_modules/matrix-react-sdk/src/SlashCommands.tsx
sed -i -e "s/\"Remove/\"${capital_remove_command}/g" \
-e "s/Failed to remove/Failed to ${remove_command}/g" "${1}"/node_modules/matrix-react-sdk/src/components/views/right_panel/UserInfo.tsx
sed -i -e "s/Removes user/${capital_remove_command_plural} user/g" \
-e "s/)s removed %(tar/)s ${remove_command_past_tense} %(tar/g" \
-e "s/\"Remove,/\"${capital_remove_command},/g" \
-e "s/You were removed/You were ${remove_command_past_tense}/g" \
-e "s/Remove from/${capital_remove_command} from/g" \
-e "s/removed\"/${remove_command_past_tense}\"/g" "${1}"/node_modules/matrix-react-sdk/src/i18n/strings/en_EN.json
sed -i -e "s/senderName)s removed %(targetName/senderName)s ${remove_command_past_tense} %(targetName/g" "${1}"/node_modules/matrix-react-sdk/src/TextForEvent.tsx
sed -i -e "s/removed/${remove_command_past_tense}/g" "${1}"/node_modules/matrix-react-sdk/src/components/views/rooms/RoomPreviewBar.tsx
sed -i -e "s/Remove users/${capital_remove_command} users/g" "${1}"/node_modules/matrix-react-sdk/src/components/views/settings/tabs/room/RolesRoomSettingsTab.tsx
sed -i -e "s/${capital_remove_command} recent/Remove recent/g" "${1}"/node_modules/matrix-react-sdk/src/i18n/strings/en_EN.json
sed -i -e "s/${capital_remove_command} recent/Remove recent/g" "${1}"/node_modules/matrix-react-sdk/src/components/views/right_panel/UserInfo.tsx
# Ban
sed -i -e "s/\"Ban\"/\"${capital_ban_command}\"/g" "${1}"/node_modules/matrix-react-sdk/src/components/views/right_panel/UserInfo.tsx || error
sed -i -e "s/Bans user with given id\",/${capital_ban_command_plural} user with given id\",/g" \
-e "s/\"Ban from %(roomName)s\",/\"${capital_ban_command} from %(roomName)s\",/g" \
-e "s/\"Ban\"/\"${capital_ban_command}\"/g" \
-e "s/\"Banned by %(displayName)s\",/\"${capital_ban_command_past_tense} by %(displayName)s\",/g" \
-e "s/\"Banned users\",/\"${capital_ban_command_past_tense} users\",/g" \
-e "s/was banned\",/was ${ban_command_past_tense}\",/g" \
-e "s/was banned %(count)s times\",/was ${ban_command_past_tense} %(count)s times\",/g" \
-e "s/were banned\",/were ${ban_command_past_tense}\",/g" \
-e "s/banned from %(roomName)s by %(memberName)s\",/${ban_command_past_tense} from %(roomName)s by %(memberName)s\",/g" \
-e "s/were banned %(count)s times\",/were ${ban_command_past_tense} %(count)s times\",/g" \
-e "s/s banned %(targetName)s: %(reason)s\",/s ${ban_command_past_tense} %(targetName)s: %(reason)s\",/g" \
-e "s/s banned %(targetName)s\",/s ${ban_command_past_tense} %(targetName)s\",/g" "${1}"/node_modules/matrix-react-sdk/src/i18n/strings/en_EN.json || error