Merge remote-tracking branch 'upstream/i18n-fix' into dev

This commit is contained in:
thororen1234 2024-11-03 12:21:23 -05:00
commit 12ce1919a9
8 changed files with 18 additions and 11 deletions

View file

@ -32,10 +32,10 @@ export default definePlugin({
} }
}, },
{ {
find: "Messages.SERVERS,children", find: '#{intl::SERVERS}"]),children',
replacement: [ replacement: [
{ {
match: /(?<=Messages\.SERVERS,children:)\i\.map\(\i\)/, match: /(?<=#{intl::SERVERS}"\]\),children:)\i\.map\(\i\)/,
replace: "Vencord.Api.ServerList.renderAll(Vencord.Api.ServerList.ServerListRenderPosition.In).concat($&)" replace: "Vencord.Api.ServerList.renderAll(Vencord.Api.ServerList.ServerListRenderPosition.In).concat($&)"
}, },
{ {

View file

@ -149,7 +149,7 @@ export default definePlugin({
patches: [{ patches: [{
find: "#{intl::BEGINNING_DM}", find: "#{intl::BEGINNING_DM}",
replacement: { replacement: {
match: /BEGINNING_DM\.format\(\{.+?\}\),(?=.{0,300}(\i)\.isMultiUserDM)/, match: /#{intl::BEGINNING_DM}"\],{.+?}\),(?=.{0,300}(\i)\.isMultiUserDM)/,
replace: "$& $self.renderContributorDmWarningCard({ channel: $1 })," replace: "$& $self.renderContributorDmWarningCard({ channel: $1 }),"
} }
}], }],

View file

@ -41,7 +41,7 @@ export default definePlugin({
{ {
find: "DefaultCustomizationSections", find: "DefaultCustomizationSections",
replacement: { replacement: {
match: /(?<=#{intl::USER_SETTINGS_AVATAR_DECORATION}\)},"decoration"\),)/, match: /(?<=#{intl::USER_SETTINGS_AVATAR_DECORATION}"\]\)},"decoration"\),)/,
replace: "$self.DecorSection()," replace: "$self.DecorSection(),"
} }
}, },

View file

@ -128,7 +128,7 @@ export default definePlugin({
{ {
find: "#{intl::USER_SETTINGS_RESET_PROFILE_THEME}", find: "#{intl::USER_SETTINGS_RESET_PROFILE_THEME}",
replacement: { replacement: {
match: /RESET_PROFILE_THEME}\)(?<=color:(\i),.{0,500}?color:(\i),.{0,500}?)/, match: /#{intl::USER_SETTINGS_RESET_PROFILE_THEME}"\]\)}\)(?<=color:(\i),.{0,500}?color:(\i),.{0,500}?)/,
replace: "$&,$self.addCopy3y3Button({primary:$1,accent:$2})" replace: "$&,$self.addCopy3y3Button({primary:$1,accent:$2})"
} }
} }

View file

@ -232,7 +232,7 @@ export default definePlugin({
} }
}, },
{ {
find: "#{ìntl::USER_PROFILE_PRONOUNS}", find: "#{intl::USER_PROFILE_PRONOUNS}",
replacement: { replacement: {
match: /(?=,hideBotTag:!0)/, match: /(?=,hideBotTag:!0)/,
replace: ",moreTags_channelId:arguments[0].moreTags_channelId" replace: ",moreTags_channelId:arguments[0].moreTags_channelId"

View file

@ -39,7 +39,7 @@ export default definePlugin({
{ {
find: "#{intl::REPLY_QUOTE_MESSAGE_NOT_LOADED}", find: "#{intl::REPLY_QUOTE_MESSAGE_NOT_LOADED}",
replacement: { replacement: {
match: /#{intl::REPLY_QUOTE_MESSAGE_NOT_LOADED}\)/, match: /#{intl::REPLY_QUOTE_MESSAGE_NOT_LOADED}"\]\)/,
replace: "$&,onMouseEnter:()=>$self.fetchReply(arguments[0])" replace: "$&,onMouseEnter:()=>$self.fetchReply(arguments[0])"
} }
}, },

View file

@ -22,6 +22,7 @@ export * from "./ChangeList";
export * from "./constants"; export * from "./constants";
export * from "./discord"; export * from "./discord";
export * from "./guards"; export * from "./guards";
export * from "./intlHash";
export * from "./lazy"; export * from "./lazy";
export * from "./lazyReact"; export * from "./lazyReact";
export * from "./localStorage"; export * from "./localStorage";

View file

@ -23,11 +23,17 @@ export function canonicalizeMatch<T extends RegExp | string>(match: T): T {
let partialCanon = typeof match === "string" ? match : match.source; let partialCanon = typeof match === "string" ? match : match.source;
partialCanon = partialCanon.replaceAll(/#{intl::([A-Za-z_$][\w$]*)}/g, (_, key) => { partialCanon = partialCanon.replaceAll(/#{intl::([A-Za-z_$][\w$]*)}/g, (_, key) => {
const hashed = runtimeHashMessageKey(key); const hashed = runtimeHashMessageKey(key);
const isStr = typeof match === "string";
return /^[\d]/.test(hashed) || !/^[\w$]+$/.test(hashed) const isString = typeof match === "string";
? isStr ? `["${hashed}` : String.raw`(?:\["${hashed}"\])` const hasSpecialChars = /^[\d]/.test(hashed) || !/^[\w$]+$/.test(hashed);
: isStr ? `.${hashed}` : String.raw`(?:\.${hashed})`;
if (hasSpecialChars) {
return isString
? `["${hashed}`
: String.raw`(?:\["${hashed})`.replaceAll("+", "\\+");
}
return isString ? `.${hashed}` : String.raw`(?:\.${hashed})`;
}); });
if (typeof match === "string") { if (typeof match === "string") {