Open History to see the last commit
1import { EDITORS, type EditorId } from "@t3tools/contracts";
2
3import { getLocalFileManagerName } from "~/lib/utils";
4import { msg } from "gt-react";
5
6import { m, type MessageResolver } from "./i18n/messages";
7
8const editorLabels = new Map<EditorId, string>(EDITORS.map((editor) => [editor.id, editor.label]));
9
10export function editorLabelForPlatform(
11 editorId: EditorId,
12 platform: string,
13 resolve: MessageResolver = m,
14): string {
15 if (editorId === "file-manager") {
16 return getLocalFileManagerName(platform, resolve);
17 }
18
19 return editorLabels.get(editorId) ?? resolve(msg({ context: "noun, a code editor app" })`Editor`);
20}
21
22export function openInEditorMenuLabel(
23 editorId: EditorId | null,
24 resolve: MessageResolver = m,
25): string {
26 return editorId === null || editorId === "file-manager"
27 ? resolve(msg("Open in editor"))
28 : resolve(
29 msg`Open in ${{
30 editor:
31 editorLabels.get(editorId) ??
32 resolve(msg({ context: "noun, a code editor app" })`Editor`),
33 }}`,
34 );
35}