-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
42 lines (32 loc) · 1.1 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const { Plugin } = require('powercord/entities');
const { React, getModule, getModuleByDisplayName, i18n } = require('powercord/webpack');
const { inject, uninject } = require('powercord/injector');
const lang = require("./i18n");
const timestamps = require("./i18n/timestamps.json")
module.exports = class TokiPona extends Plugin {
constructor () {
super();
}
async startPlugin () {
powercord.api.i18n.loadAllStrings(lang);
// dumb hack for things that don't load properly with loadAllStrings
for (const [key, value] of Object.entries(i18n.Messages)) {
if (typeof i18n.Messages[key] == "string") {
i18n.Messages[key] = lang["en-US"][key];
}
}
const timestampModule = await getModule(m => m.default?.displayName === "MessageTimestamp");
inject(
"translate-timestamp",
timestampModule,
"default",
(args, res) => {
args[0].timestamp._locale = Object.assign(args[0].timestamp._locale, timestamps);
return res;
}
);
}
pluginWillUnload () {
uninject("translate-timestamp");
}
};