diff --git a/package.json b/package.json index 3b840a2..0a76d73 100644 --- a/package.json +++ b/package.json @@ -41,8 +41,10 @@ "@types/dom-view-transitions": "^1.0.4", "@types/markdown-it": "^13.0.7", "@types/markdown-it-emoji": "^2.0.4", + "@types/sprintf-js": "^1.1.4", "fuzzball": "^2.1.2", "markdown-it": "^14.0.0", - "markdown-it-emoji": "^3.0.0" + "markdown-it-emoji": "^3.0.0", + "sprintf-js": "^1.1.3" } } \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9933492..ee53727 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,6 +20,9 @@ dependencies: '@types/markdown-it-emoji': specifier: ^2.0.4 version: 2.0.4 + '@types/sprintf-js': + specifier: ^1.1.4 + version: 1.1.4 fuzzball: specifier: ^2.1.2 version: 2.1.2 @@ -29,6 +32,9 @@ dependencies: markdown-it-emoji: specifier: ^3.0.0 version: 3.0.0 + sprintf-js: + specifier: ^1.1.3 + version: 1.1.3 devDependencies: '@skeletonlabs/skeleton': @@ -666,6 +672,10 @@ packages: resolution: {integrity: sha512-Sk/uYFOBAB7mb74XcpizmH0KOR2Pv3D2Hmrh1Dmy5BmK3MpdSa5kqZcg6EKBdklU0bFXX9gCfzvpnyUehrPIuA==} dev: true + /@types/sprintf-js@1.1.4: + resolution: {integrity: sha512-aWK1reDYWxcjgcIIPmQi3u+OQDuYa9b+lr6eIsGWrekJ9vr1NSjr4Eab8oQ1iKuH1ltFHpXGyerAv1a3FMKxzQ==} + dev: false + /acorn@8.11.2: resolution: {integrity: sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==} engines: {node: '>=0.4.0'} @@ -1716,6 +1726,10 @@ packages: resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==} engines: {node: '>=0.10.0'} + /sprintf-js@1.1.3: + resolution: {integrity: sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==} + dev: false + /string-width@4.2.3: resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} engines: {node: '>=8'} diff --git a/src/lang/en-US.json b/src/lang/en-US.json new file mode 100644 index 0000000..9dc84e2 --- /dev/null +++ b/src/lang/en-US.json @@ -0,0 +1,68 @@ +{ + "name": "English", + + "errors.something_went_wrong": "Something went wrong", + "errors.package_not_found": "Here, have a cookie, if that makes you feel any better: 🍪", + "errors.package_not_found.details": "Fun fact: You can use '@author:name' to view packages made by an author. What 'bout using '@details' to get technical details on each package?", + "errors.no_packages_published": "Looks like you don't have any approved packages published to KJSPKG. How sad!", + "errors.automatin_down": "Our statistics database seems to be down", + "errors.automatin_down.details": "Download and view counts might be missing. Please report this to", + "errors.automatin_down.server": "our Discord server", + + "menu.language": "Language", + "menu.theme": "Theme", + + "list.by": "by", + "list.detailed.on_branch": "on branch", + "list.detailed.at_path": "at path", + "list.detailed.in_repo": "in repo", + "list.download_singluar": "download", + "list.download_plural": "downloads", + "list.view_singular": "view", + "list.view_plural": "views", + + "author.owns": "owns", + "author.package_singular": "package", + "author.package_plural": "packages", + "author.you": "is you!", + "author.organizations": "Organizations", + + "author.auth_required": "To access this page, you have to first authenticate yourself through GitHub.", + "author.auth_required.login": "Log in", + + "search.placeholder": "Search for packages", + "search.package_singular": "package", + "search.package_plural": "packages", + "search.found_singular": "Found %d", + "search.found_plural": "Found %d", + "search.matching": "matching", + "search.made_by": "made by", + "search.detailed": "detailed", + + "search.show_details": "Show details", + "search.clear_filters": "Clear filters", + "search.use_view.list": "Use list view", + "search.use_view.compact": "Use compact view", + + "search.sorted_by": "Sorted by", + "search.sort_type.name": "Name (a-z)", + "search.sort_type.author": "Author (a-z)", + "search.sort_type.downloads": "Download count", + "search.sort_type.views": "View count", + "search.sorted_by.name": "name", + "search.sorted_by.author": "author", + "search.sorted_by.downloads": "downloads", + "search.sorted_by.views": "views", + + "package.created_by": "Created by", + "package.available_for": "Available for", + "package.manage_package": "Manage package (click to copy)", + "package.readme_file": "README file", + "package.package_preview": "Package preview", + + "package.depends_on": "Depends on", + "package.incompatible_with": "Incompatible with", + "package.dependency.kjs_package": "KJS package", + "package.dependency.external_mod": "external mod", + "package.dependency.mod_open_in": "Open in" +} \ No newline at end of file diff --git a/src/lang/ru-RU.json b/src/lang/ru-RU.json new file mode 100644 index 0000000..b2858dc --- /dev/null +++ b/src/lang/ru-RU.json @@ -0,0 +1,68 @@ +{ + "name": "Русский", + + "errors.something_went_wrong": "Что-то пошло не так", + "errors.package_not_found": "Вот, возьми печеньку, если это тебя подбодрит: 🍪", + "errors.package_not_found.details": "Интересный факт: В поиске можно использовать '@author:name' чтобы просмотреть пакеты от определённого автора. Также попробуйте добавить '@details' чтобы увидеть больше технической информации о каждом пакете.", + "errors.no_packages_published": "Похоже, что вы ещё не опубликовали ни одного пакета в KJSPKG. Как грустно!", + "errors.automatin_down": "Похоже, у нас неполадки с нашей базой данных", + "errors.automatin_down.details": "Кол-во загрузок и просмотров может быть недоступно. Пожалуйста, сообщите нам об этом сообщении на", + "errors.automatin_down.server": "нашем Discord сервере", + + "menu.language": "Язык", + "menu.theme": "Тема", + + "list.by": "от", + "list.detailed.on_branch": "на ветке", + "list.detailed.at_path": "в", + "list.detailed.in_repo": "в репозитории", + "list.download_singluar": "загрузка", + "list.download_plural": "загрузок", + "list.view_singular": "просмотр", + "list.view_plural": "просмотров", + + "author.owns": "владеет", + "author.package_singular": "пакетом", + "author.package_plural": "пакетами", + "author.you": "это ты!", + "author.organizations": "Организации", + + "author.auth_required": "Чтобы получить доступ к этой странице, сначала войдите через GitHub.", + "author.auth_required.login": "Войти", + + "search.placeholder": "Искать пакеты", + "search.package_singular": "пакет", + "search.package_plural": "пакетов", + "search.found_singular": "Найден %d", + "search.found_plural": "Найдено %d", + "search.matching": "по запросу", + "search.made_by": "от", + "search.detailed": "детально", + + "search.show_details": "Показать детали", + "search.clear_filters": "Очистить фильтры", + "search.use_view.list": "Использовать списочный вид", + "search.use_view.compact": "Использовать компактный вид", + + "search.sorted_by": "Отсортировано по", + "search.sort_type.name": "Название (a-z)", + "search.sort_type.author": "Автор (a-z)", + "search.sort_type.downloads": "Кол-во загрузок", + "search.sort_type.views": "Кол-во просмотров", + "search.sorted_by.name": "названию", + "search.sorted_by.author": "автору", + "search.sorted_by.downloads": "загрузкам", + "search.sorted_by.views": "просмотрам", + + "package.created_by": "Создано", + "package.available_for": "Доступно на", + "package.manage_package": "Управлять пакетом (нажмите чтобы скопировать)", + "package.readme_file": "Файл README", + "package.package_preview": "Превью пакета", + + "package.depends_on": "Зависит от", + "package.incompatible_with": "Несовместим с", + "package.dependency.kjs_package": "KJS пакет", + "package.dependency.external_mod": "сторонний мод", + "package.dependency.mod_open_in": "Открыть на" +} \ No newline at end of file diff --git a/src/lib/AuthRequired.svelte b/src/lib/AuthRequired.svelte index 041d3a6..610d1b0 100644 --- a/src/lib/AuthRequired.svelte +++ b/src/lib/AuthRequired.svelte @@ -3,6 +3,7 @@ import { PUBLIC_CLIENT_ID } from "$env/static/public"; import { IconAlertTriangle, IconBrandGithub } from "@tabler/icons-svelte"; import { fly } from "svelte/transition"; + import { langKeyStore } from "./stores"; @@ -11,10 +12,10 @@
-

To access this page, you have to first authenticate yourself through GitHub.

+

{$langKeyStore['author.auth_required']}

- Log In + {$langKeyStore['author.auth_required.login']}
\ No newline at end of file diff --git a/src/lib/HeaderBar.svelte b/src/lib/HeaderBar.svelte index 50d804d..ab347a0 100644 --- a/src/lib/HeaderBar.svelte +++ b/src/lib/HeaderBar.svelte @@ -4,11 +4,11 @@ import { page } from '$app/stores'; import { IconBlank } from '$lib'; import { AppBar } from '@skeletonlabs/skeleton'; - import { IconCheck, IconColorSwatch, IconSearch, IconUser } from '@tabler/icons-svelte'; + import { IconCheck, IconColorSwatch, IconSearch, IconWorld } from '@tabler/icons-svelte'; import consts from './consts'; import { contextMenu, type ContextMenuItem } from './overlays/contextMenu'; - import { currentScrollPosition, currentSearchStore, userPreferencesStore } from './stores'; - import { parseInputString } from './utils'; + import { currentScrollPosition, currentSearchStore, langKeyStore, userPreferencesStore } from './stores'; + import { getLangKeys, getLangs, parseInputString } from './utils'; import { fly } from 'svelte/transition'; import IconLogin from './IconLogin.svelte'; @@ -17,15 +17,34 @@ } let searched = getQuery(); + let langs = getLangs(); let inputElement: HTMLInputElement; afterNavigate(() => (searched = getQuery())); - $: settingsContextMenu = { + $: langContextMenu = { initiator: 'left' as const, items: [ - { type: 'SEPARATOR', header: 'Theme' }, + { type: 'SEPARATOR', header: $langKeyStore['menu.language'] }, + + ...Object.keys(langs).map(lang => { + return { + type: 'ITEM' as const, + label: langs[lang], + icon: $userPreferencesStore.locale == lang ? IconCheck : IconBlank, + action: () => { + $userPreferencesStore.locale = lang; + $langKeyStore = getLangKeys(); + } + }; + }) + ] as ContextMenuItem[] + }; + $: themeContextMenu = { + initiator: 'left' as const, + items: [ + { type: 'SEPARATOR', header: $langKeyStore['menu.theme'] }, ...[ { label: 'KJSPKG', name: 'kjspkg' }, @@ -119,7 +138,7 @@ ($currentSearchStore = searched)} @@ -135,7 +154,13 @@ + diff --git a/src/lib/project/Author.svelte b/src/lib/project/Author.svelte index 0d8cbf2..1705e8f 100644 --- a/src/lib/project/Author.svelte +++ b/src/lib/project/Author.svelte @@ -1,7 +1,7 @@ @@ -28,8 +22,8 @@ {#if o} - - {#if o.t} -
- {@html markdownInline(o.t)} -
- {/if} {:else}
{/if} diff --git a/src/lib/project/Organizations.svelte b/src/lib/project/Organizations.svelte index 39c82a2..31701ae 100644 --- a/src/lib/project/Organizations.svelte +++ b/src/lib/project/Organizations.svelte @@ -1,11 +1,12 @@
-
Organizations
+
{$langKeyStore['author.organizations']}
{#each orgs as org}
{org.login}
- owns {org.pkg_count} - {org.pkg_count == 1 ? 'package' : 'packages'} + {$langKeyStore['author.owns']} {org.pkg_count} + {$langKeyStore[org.pkg_count == 1 ? 'author.package_singular' : 'author.package_plural']}
diff --git a/src/lib/project/PackageList.svelte b/src/lib/project/PackageList.svelte index f4ae781..d89603e 100644 --- a/src/lib/project/PackageList.svelte +++ b/src/lib/project/PackageList.svelte @@ -2,7 +2,7 @@ import { base } from '$app/paths'; import { page } from '$app/stores'; import consts from '$lib/consts'; - import { packageStatStore } from '$lib/stores'; + import { langKeyStore, packageStatStore } from '$lib/stores'; import { packageNameToReadableFormat } from '$lib/utils'; import { createEventDispatcher } from 'svelte'; import { flip } from 'svelte/animate'; @@ -86,22 +86,22 @@
{packageNameToReadableFormat(name)}
{#if branch && showDetails} - on branch {branch.substring(1)} + {$langKeyStore['list.detailed.on_branch']} {branch.substring(1)} {/if} {#if path && showDetails} - at path {path.substring(1)} + {$langKeyStore['list.detailed.at_path']} {path.substring(1)} {/if} {#if name != repo && showDetails} - in repo {repo} + {$langKeyStore['list.detailed.in_repo']} {repo} {/if} {#if showName} - by {author} + {$langKeyStore['list.by']} {author} {/if}
- {statDownloads} download{statDownloads == 1 ? '' : 's'} • - {statViews} view{statViews == 1 ? '' : 's'} + {statDownloads} {statDownloads == 1 ? $langKeyStore['list.download_singluar'] : $langKeyStore['list.download_plural']} • + {statViews} {statViews == 1 ? $langKeyStore['list.view_singular'] : $langKeyStore['list.view_plural']}
diff --git a/src/lib/project/PackagePreview.svelte b/src/lib/project/PackagePreview.svelte index 5bea24e..d62e964 100644 --- a/src/lib/project/PackagePreview.svelte +++ b/src/lib/project/PackagePreview.svelte @@ -1,6 +1,6 @@