diff --git a/package.json b/package.json index 527726c3..df65bd2a 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "bugs": { "url": "https://github.com/spicetify/spicetify-marketplace/issues" }, - "packageManager": "pnpm@8.10.5", + "packageManager": "pnpm@8.14.2", "scripts": { "build": "spicetify-creator", "build:local": "spicetify-creator --out=dist --minify", diff --git a/src/components/Card/Card.tsx b/src/components/Card/Card.tsx index 004ff736..72834bd7 100644 --- a/src/components/Card/Card.tsx +++ b/src/components/Card/Card.tsx @@ -177,7 +177,7 @@ class Card extends React.Component setTimeout(resolve, 10)); + if (!Spicetify.LocalStorage || !Spicetify.showNotification) { + setTimeout(init, 100); + return; } // https://github.com/satya164/react-simple-code-editor/issues/86 @@ -159,7 +160,7 @@ import { if (!tld) { if (window.navigator.onLine) { console.error(new Error("Unable to connect to the CDN, please check your Internet configuration.")); - Spicetify.showNotification("Marketplace is unable to connect to the CDN. Please check your Internet configuration.", true, 5000); + Spicetify.showNotification(t("notifications.noCdnConnection"), true, 5000); } else { // Reload Marketplace extension in case the user couldn't connect to the CDN because they were offline window.addEventListener("online", init, { once: true }); @@ -178,11 +179,7 @@ import { const installedTheme = localStorage.getItem(LOCALSTORAGE_KEYS.themeInstalled); if (installedTheme) { if (localTheme.toLocaleLowerCase() !== "marketplace") { - Spicetify.showNotification( - t("notifications.wrongLocalTheme"), - true, - 5000, - ); + Spicetify.showNotification(t("notifications.wrongLocalTheme"), true, 5000); return; } initializeTheme(installedTheme); @@ -206,7 +203,7 @@ async function queryRepos(type: RepoType, pageNum = 1) { .catch(() => null); if (!allRepos?.items) { - Spicetify.showNotification?.("Too Many Requests, Cool Down.", true); + Spicetify.showNotification(t("notifications.tooManyRequests"), true, 5000); return { items: [] }; } diff --git a/src/logic/FetchRemotes.ts b/src/logic/FetchRemotes.ts index 5f156841..f69d2263 100644 --- a/src/logic/FetchRemotes.ts +++ b/src/logic/FetchRemotes.ts @@ -1,8 +1,8 @@ +import { t } from "i18next"; + import { BLACKLIST_URL, ITEMS_PER_REQUEST } from "../constants"; -import { CardItem, Snippet } from "../types/marketplace-types"; import { addToSessionStorage, processAuthors } from "./Utils"; - -import { RepoTopic } from "../types/marketplace-types"; +import { RepoTopic, CardItem, Snippet } from "../types/marketplace-types"; import snippetsJSON from "../resources/snippets"; // TODO: add sort type, order, etc? @@ -30,7 +30,7 @@ export async function getTaggedRepos(tag: RepoTopic, page = 1, BLACKLIST:string[ .catch(() => null); if (!allRepos?.items) { - Spicetify.showNotification("Too Many Requests, Cool Down.", true); + Spicetify.showNotification(t("notifications.tooManyRequests"), true, 5000); return { items: [] }; } diff --git a/src/logic/Utils.ts b/src/logic/Utils.ts index b71b5b2e..38fa9895 100644 --- a/src/logic/Utils.ts +++ b/src/logic/Utils.ts @@ -1,7 +1,10 @@ +import Chroma from "chroma-js"; +import { t } from "i18next"; + import { CardProps } from "../components/Card/Card"; import { Author, CardItem, ColourScheme, SchemeIni, Snippet, SortBoxOption, ResetCategory } from "../types/marketplace-types"; -import Chroma from "chroma-js"; import { LOCALSTORAGE_KEYS } from "../constants"; + /** * Get localStorage data (or fallback value), given a key * @param key The localStorage key @@ -562,7 +565,10 @@ export async function getMarkdownHTML(markdown: string, user: string, repo: stri method: "POST", body: JSON.stringify(postBody), }); - if (!response.ok) throw Spicetify.showNotification(`Error parsing markdown (HTTP ${response.status})`, true); + if (!response.ok) throw Spicetify.showNotification( + t("notifications.markdownParsingError", { status: response.status }), + true, + ); const html = await response.text(); diff --git a/src/resources/locales/en.json b/src/resources/locales/en.json index 121f4a18..a37f763b 100644 --- a/src/resources/locales/en.json +++ b/src/resources/locales/en.json @@ -33,6 +33,7 @@ }, "snippets": { "addTitle": "Add Snippet", + "duplicateName": "That name is already taken!", "editTitle": "Edit Snippet", "viewTitle": "View Snippet", "customCSS": "Custom CSS", @@ -80,7 +81,7 @@ "whatsChanged": "What's Changed", "seeChangelog": "See changelog", "howToUpgrade": "How to upgrade", - "viewGuide": "View install guide" + "viewGuide": "View guide" }, "grid": { "spicetifyMarketplace": "Spicetify Marketplace", @@ -116,7 +117,13 @@ "colour_other": "colours", "favourite": "favourite", "notifications": { - "wrongLocalTheme": "Please set current_theme in config-xpui.ini to 'marketplace' to install themes using the Marketplace." + "wrongLocalTheme": "Please set current_theme in config-xpui.ini to 'marketplace' to install themes using the Marketplace", + "tooManyRequests": "Too many requests, cool down", + "noCdnConnection": "Marketplace is unable to connect to the CDN. Please check your Internet configuration", + "markdownParsingError": "Error parsing markdown (HTTP {{status}})", + "noReadmeFile": "No README was found", + "themeInstallationError": "There was an error installing theme", + "extensionInstallationError": "There was an error installing extension" } } } diff --git a/src/resources/locales/ru.json b/src/resources/locales/ru.json index 47929268..584122e3 100644 --- a/src/resources/locales/ru.json +++ b/src/resources/locales/ru.json @@ -33,6 +33,7 @@ }, "snippets": { "addTitle": "Добавление сниппета", + "duplicateName": "Сниппет с таким названием уже существует", "editTitle": "Редактирование сниппета", "viewTitle": "Просмотр сниппета", "customCSS": "CSS", @@ -116,7 +117,13 @@ "colour_other": "цвета", "favourite": "избранное", "notifications": { - "wrongLocalTheme": "Пожалуйста, измените значение current_theme в config-xpui.ini на 'marketplace', чтобы устанавливать темы из Маркетплейса" + "wrongLocalTheme": "Пожалуйста, измените значение current_theme в config-xpui.ini на 'marketplace', чтобы использовать темы из Маркетплейса", + "tooManyRequests": "Слишком много запросов. Пожалуйста, попробуйте позже", + "noCdnConnection": "Маркетплейс не может подключиться к CDN. Пожалуйста, попробуйте позже", + "markdownParsingError": "Ошибка при парсинге Markdown (HTTP {{status}})", + "noReadmeFile": "README не найден", + "themeInstallationError": "Ошибка при установке темы", + "extensionInstallationError": "Ошибка при установке расширения" } } } diff --git a/src/settings.json b/src/settings.json index 6acfd7ad..d3c4ba93 100644 --- a/src/settings.json +++ b/src/settings.json @@ -1,5 +1,8 @@ { - "displayName": "Marketplace", + "displayName": { + "en": "Marketplace", + "ru": "Маркетплейс" + }, "nameId": "marketplace", "icon": "assets/icon.svg", "activeIcon": "assets/icon-filled.svg"