mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-08 14:13:01 -04:00
Fix all plugins for new i18n lib (#2993)
This commit is contained in:
parent
5216bcca1e
commit
00f82e96bd
89 changed files with 351 additions and 238 deletions
|
@ -19,12 +19,39 @@
|
|||
import "./discord.css";
|
||||
|
||||
import { MessageObject } from "@api/MessageEvents";
|
||||
import { ChannelStore, ComponentDispatch, Constants, FluxDispatcher, GuildStore, InviteActions, MessageActions, PrivateChannelsStore, RestAPI, SelectedChannelStore, SelectedGuildStore, UserProfileActions, UserProfileStore, UserSettingsActionCreators, UserUtils } from "@webpack/common";
|
||||
import { ChannelStore, ComponentDispatch, Constants, FluxDispatcher, GuildStore, i18n, InviteActions, MessageActions, PrivateChannelsStore, RestAPI, SelectedChannelStore, SelectedGuildStore, UserProfileActions, UserProfileStore, UserSettingsActionCreators, UserUtils } from "@webpack/common";
|
||||
import { Channel, Guild, Message, User } from "discord-types/general";
|
||||
import { Except } from "type-fest";
|
||||
|
||||
import { runtimeHashMessageKey } from "./intlHash";
|
||||
import { Logger } from "./Logger";
|
||||
import { MediaModalItem, MediaModalProps, openMediaModal } from "./modal";
|
||||
|
||||
const IntlManagerLogger = new Logger("IntlManager");
|
||||
|
||||
/**
|
||||
* Get an internationalized message from a non hashed key
|
||||
* @param key The plain message key
|
||||
* @param values The values to interpolate, if it's a rich message
|
||||
*/
|
||||
export function getIntlMessage(key: string, values?: Record<PropertyKey, any>): any {
|
||||
return getIntlMessageFromHash(runtimeHashMessageKey(key), values, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an internationalized message from a hashed key
|
||||
* @param hashedKey The hashed message key
|
||||
* @param values The values to interpolate, if it's a rich message
|
||||
*/
|
||||
export function getIntlMessageFromHash(hashedKey: string, values?: Record<PropertyKey, any>, originalKey?: string): any {
|
||||
try {
|
||||
return values == null ? i18n.intl.string(i18n.t[hashedKey]) : i18n.intl.format(i18n.t[hashedKey], values);
|
||||
} catch (e) {
|
||||
IntlManagerLogger.error(`Failed to get intl message for key: ${originalKey ?? hashedKey}`, e);
|
||||
return originalKey ?? "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the invite modal
|
||||
* @param code The invite code
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue