2024-10-27 02:07:41 -04:00
|
|
|
/*
|
|
|
|
|
* Vencord, a Discord client mod
|
|
|
|
|
* Copyright (c) 2024 Vendicated and contributors
|
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
*/
|
|
|
|
|
|
2025-12-06 00:49:53 -05:00
|
|
|
import { isPluginEnabled } from "@api/PluginManager";
|
|
|
|
|
import anonymiseFileNames, { tarExtMatcher } from "@plugins/anonymiseFileNames";
|
2025-09-08 21:48:40 -04:00
|
|
|
import { Devs } from "@utils/constants";
|
feat(i18n): Add translation keys and implement localization for 80+ p… (#772)
* feat(i18n): Add translation keys and implement localization for 80+ plugins
- Add comprehensive translation keys to i18n/en-US/vencord.json
- Update all plugins to use t() function from @utils/translation
- Replace hardcoded strings with translation function calls
- Support plural forms with _one/_other suffixes
- Use Translate component for strings with embedded JSX
Plugins translated include:
- Core: reviewDB, translate, voiceMessages, messageLogger
- UI: showHiddenChannels, customRPC, clientTheme, permissionsViewer
- Utility: betterSessions, betterSettings, memberCount, betterFolders
- Social: relationshipNotifier, messageLatency, whoReacted
- Media: imageZoom, viewIcons, viewRaw, decor, fakeNitro
- And 60+ more plugins
All changes pass TypeScript compilation.
* Update i18n/en-US/vencord.json
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* Update i18n/en-US/vencord.json
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* Update i18n/en-US/vencord.json
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* Update i18n/en-US/vencord.json
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* Update i18n/en-US/vencord.json
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* Update i18n/en-US/vencord.json
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* feat(i18n): Add equicord.json for equicordplugins localization
- Create i18n/en-US/equicord.json with messageLoggerEnhanced translation keys
- Create empty equicord.json files for all other locales (Crowdin will handle translations)
- Build system automatically picks up all JSON files in i18n/{locale}/
* Update i18n/en-US/vencord.json
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* feat(i18n): Add translations to 200 equicordplugins
- Translate all user-facing strings in equicordplugins to use t() function
- Add translation keys to i18n/en-US/equicord.json
- Plugin names remain static strings for build system compatibility
- Settings descriptions, tooltips, context menus, and UI strings now translatable
* FileUpload: add sharex file support (#771)
* FileUpload: add sharex file support
Quick note, the settings seem to split pacal case with spaces for some reason,
so `ShareX` renders as `Share X`. This is stupid and im upset and I dont think
theres anything I can do about it
* FileUpload: use Headers object to construct HTTP headers
* Update vencord.json
---------
Co-authored-by: Mishal <91066601+mishalhossin@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Key <keircn@proton.me>
Co-authored-by: thororen1234 <78185467+thororen1234@users.noreply.github.com>
2026-02-15 20:39:58 +06:00
|
|
|
import { t } from "@utils/translation";
|
2024-10-28 21:59:06 -04:00
|
|
|
import definePlugin, { ReporterTestable } from "@utils/types";
|
2025-09-08 22:01:55 -04:00
|
|
|
import { CloudUpload } from "@vencord/discord-types";
|
2024-10-27 02:07:41 -04:00
|
|
|
|
2025-02-14 02:46:00 -05:00
|
|
|
const extensionMap = {
|
2026-01-14 19:11:24 -05:00
|
|
|
"ogg": [".ogv", ".oga", ".ogx", ".ogm", ".spx", ".aac", ".wma"],
|
|
|
|
|
"jpg": [".jpe", ".jif", ".jfi", ".pjpeg", ".pjp", ".bmp", ".tiff", ".tif"],
|
2025-09-28 09:36:55 -04:00
|
|
|
"svg": [".svgz", ".ai", ".eps"],
|
2026-01-14 19:11:24 -05:00
|
|
|
"mp4": [".m4v", ".m4r", ".m4p", ".avi", ".mkv", ".wmv", ".flv", ".3gp"],
|
|
|
|
|
"m4a": [".m4b", ".aiff"],
|
2025-09-28 09:36:55 -04:00
|
|
|
"mov": [".movie", ".qt", ".asf", ".rm", ".rmvb"],
|
|
|
|
|
"png": [".ico", ".cur"],
|
2025-02-14 02:46:00 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const reverseExtensionMap = Object.entries(extensionMap).reduce((acc, [target, exts]) => {
|
|
|
|
|
exts.forEach(ext => acc[ext] = `.${target}`);
|
|
|
|
|
return acc;
|
|
|
|
|
}, {} as Record<string, string>);
|
2024-10-27 19:17:25 -04:00
|
|
|
|
2024-10-27 02:07:41 -04:00
|
|
|
export default definePlugin({
|
|
|
|
|
name: "FixFileExtensions",
|
2025-09-08 21:48:40 -04:00
|
|
|
authors: [Devs.thororen],
|
2026-03-03 12:14:28 -05:00
|
|
|
description: t("equicord.fixFileExtensions.description"),
|
2026-04-16 13:45:58 -04:00
|
|
|
tags: ["Media", "Utility"],
|
2024-10-28 21:59:06 -04:00
|
|
|
reporterTestable: ReporterTestable.None,
|
2024-10-27 02:07:41 -04:00
|
|
|
patches: [
|
2024-10-27 02:16:11 -04:00
|
|
|
// Taken from AnonymiseFileNames
|
2024-10-27 02:07:41 -04:00
|
|
|
{
|
2025-06-17 09:08:35 -04:00
|
|
|
find: "async uploadFiles(",
|
2025-06-04 20:46:38 -04:00
|
|
|
replacement: [
|
|
|
|
|
{
|
2025-06-17 09:08:35 -04:00
|
|
|
match: /async uploadFiles\((\i)\){/,
|
2025-06-04 22:09:30 -04:00
|
|
|
replace: "$&$1.forEach($self.fixExt);"
|
2025-06-04 20:46:38 -04:00
|
|
|
}
|
|
|
|
|
],
|
2025-12-06 00:49:53 -05:00
|
|
|
predicate: () => !isPluginEnabled(anonymiseFileNames.name),
|
2024-10-27 02:07:41 -04:00
|
|
|
},
|
|
|
|
|
],
|
2025-09-08 22:01:55 -04:00
|
|
|
fixExt(upload: CloudUpload) {
|
2024-10-27 02:07:41 -04:00
|
|
|
const file = upload.filename;
|
2025-04-07 09:45:49 -04:00
|
|
|
const tarMatch = tarExtMatcher.exec(file);
|
|
|
|
|
const extIdx = tarMatch?.index ?? file.lastIndexOf(".");
|
2025-04-08 09:09:21 -04:00
|
|
|
const fileName = extIdx !== -1 ? file.substring(0, extIdx) : "";
|
2024-10-27 02:07:41 -04:00
|
|
|
const ext = extIdx !== -1 ? file.slice(extIdx) : "";
|
|
|
|
|
const newExt = reverseExtensionMap[ext] || ext;
|
|
|
|
|
|
2025-09-28 09:36:55 -04:00
|
|
|
upload.filename = fileName + newExt;
|
2024-10-27 02:07:41 -04:00
|
|
|
},
|
|
|
|
|
});
|