Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

editorLabels.ts

37 lines1.0 KB

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 (
20 editorLabels.get(editorId) ?? resolve(msg("Editor", { $context: "noun, a code editor app" }))
21 );
23​
24export function openInEditorMenuLabel(
25 editorId: EditorId | null,
26 resolve: MessageResolver = m,
27): string {
28 return editorId === null || editorId === "file-manager"
29 ? resolve(msg("Open in editor"))
30 : resolve(
31 msg("Open in {editor}", {
32 editor:
33 editorLabels.get(editorId) ??
34 resolve(msg("Editor", { $context: "noun, a code editor app" })),
35 }),
36 );