дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-05 17:47:08 +02:00
In the Chinese UI, Rename on a folder named `tasks` read 将目录“任务”及其用法重命名为:. The `tx` template tag translated every interpolated string that had a catalog entry of its own, so a file, branch, script or container name that matched a UI word (`tasks`, `Retry`) was shown translated. Values are now inserted as written. Call sites that interpolate the app's own UI words (kind labels, option titles, "Source"/"Target") mark them with the new `txPart(...)`, which is also translated again after a language change; the text catalog guard checks `txPart` literals too. `txTemplate` still translates captured parts. Co-authored-by: wildcatDownstairs <[email protected]>
47 рядки
1.6 KiB
TypeScript
47 рядки
1.6 KiB
TypeScript
/** Navigate › File Path (⌥⌘F12): the file and its folders, each revealed in the OS file manager. */
|
||
import { openPopup } from "@/editor/lsp/popupStore";
|
||
import { canRevealInFileManager, fileManagerName, revealInFileManager } from "@/platform/fileManager";
|
||
import { notifications } from "@/workbench/contributions";
|
||
import { tx, txPart } from "@/platform/i18n";
|
||
import { nameOf, parentOf } from "./paths";
|
||
import { notifyRevealUnavailable } from "./operations";
|
||
|
||
const DRIVE_ROOT = /^[A-Za-z]:\/?$/;
|
||
|
||
/** `path` then each folder above it, up to the file system (or drive) root. */
|
||
export function filePathChain(path: string): string[] {
|
||
const out = [path];
|
||
for (let p = path; p !== "/" && !DRIVE_ROOT.test(p);) {
|
||
const parent = parentOf(p);
|
||
if (parent === p) break;
|
||
p = /^[A-Za-z]:$/.test(parent) ? `${parent}/` : parent;
|
||
out.push(p);
|
||
}
|
||
return out;
|
||
}
|
||
|
||
async function reveal(path: string) {
|
||
try {
|
||
await revealInFileManager(path);
|
||
} catch (e) {
|
||
const fileManager = txPart(fileManagerName());
|
||
notifications().notify({
|
||
level: "error",
|
||
title: tx`Cannot reveal in ${fileManager}`,
|
||
body: e instanceof Error ? e.message : String(e),
|
||
});
|
||
}
|
||
}
|
||
|
||
export function showFilePathPopup(path: string, isDir = false) {
|
||
if (!canRevealInFileManager()) return notifyRevealUnavailable();
|
||
const items = filePathChain(path).map((p, i) => ({
|
||
id: p,
|
||
label: nameOf(p) || p,
|
||
detail: i === 0 ? undefined : p,
|
||
icon: i === 0 && !isDir ? "file" : "folder",
|
||
run: () => reveal(p),
|
||
}));
|
||
openPopup({ kind: "list", anchor: { x: window.innerWidth / 2 - 160, y: 96 }, title: "File Path", items });
|
||
}
|