An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
let englishLanguages: Record<string, string> | undefined;
let englishLanguagesPromise: Promise<Record<string, string> | undefined> | undefined;
export const getEnglishCommandLabel = (key: string) => englishLanguages?.[key];
export const requestEnglishCommandTranslations = async (
version: string,
fetcher: typeof fetch = fetch,
) => {
const response = await fetcher(`/appearance/langs/en.json?v=${version}`, {cache: "no-store"});
if (!response.ok) {
throw new Error(`Unable to load English commands: ${response.status}`);
}
return response.json() as Promise<Record<string, string>>;
};
export const initializeEnglishCommandTranslations = (
currentLanguage: string,
currentLanguages: Record<string, string>,
version: string,
) => {
if (currentLanguage === "en") {
englishLanguages = currentLanguages;
return Promise.resolve(englishLanguages);
}
if (!englishLanguagesPromise) {
englishLanguagesPromise = requestEnglishCommandTranslations(version)
.then(languages => {
englishLanguages = languages;
return languages;
})
.catch((error): undefined => {
console.warn("Unable to load English command translations:", error);
return undefined;
});
}
return englishLanguagesPromise;
};