Skip to content
This repository has been archived by the owner on Jan 15, 2025. It is now read-only.

Commit

Permalink
Merge branch 'main' into burmese-language
Browse files Browse the repository at this point in the history
  • Loading branch information
nopapername committed Mar 19, 2024
2 parents 65da66d + 9ba8bd3 commit 7c23eb8
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 11 deletions.
37 changes: 27 additions & 10 deletions svelte/src/libs/search-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import log from "$libs/logger";
let packagesIndex: Fuse<GUIPackage>;
let ready = false;

// Set search timeout (milliseconds)
const SEARCH_TIMEOUT_MS = 10000;

export function indexPackages(packages: GUIPackage[]) {
try {
packagesIndex = new Fuse(packages, {
Expand Down Expand Up @@ -46,22 +49,36 @@ export function indexPackages(packages: GUIPackage[]) {
export async function searchPackages(term: string, limit = 5): Promise<GUIPackage[]> {
await isIndexReady();
if (!term || !packagesIndex) return [];
// TODO: if online, use algolia else use Fuse
const res = packagesIndex.search(term, { limit });
const matchingPackages: GUIPackage[] = res.map((v) => v.item);
return matchingPackages;

// Use try-catch to catch exceptions in asynchronous operations
try {
// Set timeout using Promise.race
const matchingPackages = await Promise.race([
packagesIndex.search(term, { limit }), // TODO: if online, use algolia else use Fuse
new Promise((resolve) => setTimeout(resolve, SEARCH_TIMEOUT_MS))
]);

// Return matching packages
return matchingPackages.map((v) => v.item);
} catch (error) {
console.error('Error searching packages:', error);
return [];
}
}

export async function isIndexReady(): Promise<boolean> {
if (ready) return true;
return new Promise((resolve) => {
const intervalCancel = setInterval(() => {
export async function isIndexReady(): Promise<void> {
// If the index is ready, return immediately
if (ready) return;

// Set a timer to check whether the index is ready every second
await new Promise((resolve) => {
const interval = setInterval(() => {
if (packagesIndex) {
const [grep] = packagesIndex.search("grep");
if (grep) {
clearInterval(intervalCancel);
clearInterval(interval);
ready = true;
resolve(true);
resolve();
}
}
}, 1000);
Expand Down
4 changes: 3 additions & 1 deletion svelte/src/libs/translations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import sk from "./languages/sk.json";
import ee from "./languages/ee.json";
import srb from "./languages/srb.json";
import is from "./languages/is.json";
import lo from "./languages/lo.json";

import * as customModifiers from "./modifiers";

Expand Down Expand Up @@ -93,7 +94,8 @@ const languages = [
sk,
ee,
srb,
is
is,
lo
];

const langs: { [lang: string]: string } = {};
Expand Down
101 changes: 101 additions & 0 deletions svelte/src/libs/translations/languages/lo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"id": "lo",
"label": "Lao",
"translations": {
"store-search-placeholder": "ຄົ້ນຫາ​ການ​ຕິດ​ຕັ້ງ",
"action": {
"update": "ປັບ​ປ່ຽນ",
"cancel": "ຍົກເລີກ"
},
"package": {
"update-all": "ປັບ​ປ່ຽນ​ທັງ​ຫມົດ",
"cta-AVAILABLE": "ຕິດ​ຕັ້ງ",
"cta-INSTALLED": "ຕິດ​ຕັ້ງ​ແລ້ວ",
"cta-INSTALLING": "ກຳ​ລັງ​ຕິດ​ຕັ້ງ",
"cta-UNINSTALLED": "ຕິດ​ຕັ້ງ​ຄືນ",
"cta-UNINSTALL": "ຍົກ​ລັບ",
"cta-NEEDS_UPDATE": "ປັບ​ປ່ຽນ",
"cta-UPDATING": "ກຳ​ລັງ​ປັບ​ປ່ຽນ",
"cta-UPDATED": "ປັບ​ປ່ຽນ​ແລ້ວ",
"cta-PRUNE": "ບັນ​ດາຍ",
"cta-PRUNING": "ກຳ​ລັງ​ບັນ​ດາຍ",
"open": "ສິນ​ສຸດ",
"open-in-terminal": "ສິນ​ສຸດ​ຢາກ​ໃຊ້​ເຄື່ອງ​ດື່ມ",
"local-package": "ການຕິດຕັ້ງໃນໂຄງການອາຊີບິດ",
"not-in-pantry": "ບໍ່ຖືກເພີ່ມໄປຫາຄຸນນະພາບຄືນທີ່"
},
"footer": {
"quick-links-title": "ລິ້ງລາຍການດ່ວນຫຼຸດ",
"about-tea-store": "ກ່ຽວກັບຮ້ານຊື້ຊາຍ",
"report-a-problem": "ລາຍງານບາດຜິດພາດ",
"visit-website": "ເຂົ້າໜ້າເວັບອີລ",
"terms-services": "ເງື່ອນໄຂ & ບໍລິການ",
"privacy-policy": "ຂໍ້ມູນທົດສອບລະບົບສະຫຼັບການຂໍຂອບໃຈ"
},
"documentation": {
"title": "ເອກະສານລາຍຊື່",
"workshops": "ສະຖິຕິວຽກ"
},
"view-all": "ເບິ່ງທັງໝົດ",
"sorting": {
"label": "ລຽງລຳດັບຕາມ",
"popularity": "ສຳລັບຜູ້ເລືອກປະສົບການດີທີ່ສຳພັນສົມບັດ",
"most-recent": "ສຳລັບການຫຼາຍໃຫມ່ທີ່ປະຈຳ"
},
"common": {
"home": "ໜ້າຫຼັກ",
"all": "ທັງໝົດ",
"articles": "ບົດຄວາມ",
"workshops": "ສະຫງວນການ",
"metadata": "ເລືອກບົດຄວາມ",
"homepage": "ໜ້າທຳອິດ",
"documentation": "ເອກະສານ",
"github-repository": "Github Repository",
"repository": "ບ່ອນເກັບຂໍ້ມູນ",
"contributors": "ຜູ້ສ້າງວຽກ",
"view-on-github": "ເບິ່ງໃນ GITHUB"
},
"tabs": {
"details": "pkg",
"cli": "cli",
"gui": "gui"
},
"notification": {
"update-header": "ປັບປຸງ tea/gui ເຂົ້າຮ່ວມກັບ {{version}}?",
"gui-restarting": "ການປັບປຸງກັບການປາກຫຼັງການຈັດການແປງສຳລັບສ່ວນອື່ນຫຼາຍແມ່ນ. ກະລຸນາວ່າທ່ານບໍ່ມີຂໍ້ມູນທີ່ຍັງກຳລັງປະຕິບັດ. ທ່ານຕ້ອງຕົກລົງບໍ? ",
"gui-restart": "ປາກຫຼັງ"
},
"side-menu-title": {
"discover": "ຊອກຫາ",
"all": "ທັງໝົດຂອງການຕິດຕັ້ງ",
"installed": "ຕິດຕັ້ງແລ້ວລະບົບ",
"installed_updates_available": "ມີການປັບປຸງທີ່ມີຢູ່",
"recently_updated": "ປັບປຸງໃໝ່ວັນນີ້",
"new_packages": "ແຜນຫຼັງໃໝ່",
"popular": "ທີ່ຖືກຕິດຕັ້ງ",
"featured": "ສະແດງຄຸນນະພາບ",
"essentials": "ສິ່ງທີ່ກວດສອບໄວ້",
"starstruck": "Starstruck Heavyweights",
"made_by_tea": "ຜະລິດຂອງ tea",
"local_packages": "ແຜນຫຼັງຂອງເມືອງ"
},
"tags": {
"discover": "ຊອກຫາ",
"all": "ທັງໝົດຂອງການຕິດຕັ້ງ",
"installed": "ຕິດ​ຕັ້ງ​ແລ້ວ",
"installed_updates_available": "ມີການປັບປຸງທີ່ມີຢູ່",
"recently_updated": "ປັບປຸງໃໝ່ວັນນີ້",
"new_packages": "ແຜນຫຼັງໃໝ່",
"popular": "ທີ່ຖືກຕິດຕັ້ງຫຼາຍກວ່າຄ່າ",
"featured": "ສະແດງຄຸນສຳລັບ",
"essentials": "ສິ່ງທີ່ກໍາຫນ່ວຍ",
"starstruck": "starstruck",
"made_by_tea": "ຜະລິດຂອງ tea",
"local_packages": "ແຜນຫຼັງພະຍາຍາມ"
},
"discover": {
"featured_title": "ການເຮັດວຽກອັງກິດ AI ຢູ່ຕາມບັນດາ",
"featured_description": "ການສຳຫຼັບຕົວຢ່າງຂອງ AI ຕາມບັນດາ. ນັກຮົບຜົນດ້ວຍຄວາມຮູ້ສຶກສາຂອງ AI ສູງສຸດເຊິ່ງ AutoGPT ແລະ Stable Diffusion Web UI, ຈາກລະບົບຂອງທ່ານຕາມຕົວຢ່າງ. ການເລີ່ມຕົ້ນຂອງການປະກອບ AI ແລະສະຫງວນຂໍ້ມູນຂອງທ່ານເປັນຄວາມປອດໄພແລະປົກກະຕິໃນການຕັ້ງຄ່າສາມາດ. ມັນມີຄວາມທາງລະບຸໄປທີ່ທ່ານຈະຈະກວດສອບໄດ້."
}
}
}

0 comments on commit 7c23eb8

Please sign in to comment.