[feat] changed proton logs tippy text

* fixed issue with translation code where strings with "[]" characters throws an error
This commit is contained in:
silentrald
2024-12-22 13:07:43 +08:00
parent a54f81de42
commit cb755215b5
3 changed files with 11 additions and 4 deletions
+1 -1
View File
@@ -58,7 +58,7 @@
"map-editor": "Map Editor",
"map-editor-description": "Start the official Beat Saber map editor instead of the game.",
"proton-logs": "Proton Logs",
"proton-logs-description": "Writes the proton logs within the Beat Saber version. To access logs, go to \"Version Settings ⚙️ > Open Folder > Open `Logs` Folder\"."
"proton-logs-description": "Enables the recording of proton logs for this Beat Saber install to \"{versionPath}\"."
},
"maps": {
"search-bar": {
@@ -2,7 +2,7 @@ import Tippy from "@tippyjs/react";
import { GlowEffect } from "renderer/components/shared/glow-effect.component";
import { BsmIcon } from "renderer/components/svgs/bsm-icon.component";
import { SvgIcon } from "renderer/components/svgs/svg-icon.type";
import { useTranslation } from "renderer/hooks/use-translation.hook";
import { useTranslationV2 } from "renderer/hooks/use-translation.hook";
type Props = {
onClick: (active: boolean) => void;
@@ -13,7 +13,7 @@ type Props = {
};
export function LaunchModToogle({ onClick, active, text, icon: Icon, infoText }: Props) {
const t = useTranslation();
const { text: t } = useTranslationV2();
return (
<button className={`shrink-0 relative rounded-full cursor-pointer group active:scale-95 transition-transform ${!active && "shadow-md shadow-black"}`} onClick={() => onClick(!active)}>
+8 -1
View File
@@ -5,6 +5,7 @@ import { ConfigurationService } from "./configuration.service";
import { getProperty } from "dot-prop";
import { i18n } from "dateformat";
import { createElement, Fragment } from "react";
import { logRenderError } from "renderer";
export class I18nService {
private static instance: I18nService;
@@ -79,7 +80,13 @@ export class I18nService {
public translate(translationKey: string, args?: Record<string, string>): string {
let translated = this.cache.get(translationKey);
if (!translated) {
translated = getProperty(this.dictionary, translationKey) ?? translationKey;
try {
translated = getProperty(this.dictionary, translationKey) ?? translationKey;
} catch (error) {
// Invalid translationKey like strings containing "[]"
logRenderError(`Could not get property of ${translationKey}`, error);
translated = translationKey;
}
this.cache.set(translationKey, translated);
}