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

fileExplorerLabel.ts

30 lines1.2 KB

1import type { ExecutionEnvironmentPlatformOs, FileManagerRevealKind } from "@t3tools/contracts";
2import { msg } from "gt-react";
3​
4import { m, type MessageResolver } from "~/i18n/messages";
5​
6/** Components pass `useMessages()` so labels follow a language switch. */
7export function revealInFileExplorerLabel(platform: string, resolve: MessageResolver = m): string {
8 const normalized = platform.toLowerCase();
9 if (normalized.includes("mac")) return resolve(msg("Reveal in Finder"));
10 if (normalized.includes("win")) return resolve(msg("Reveal in File Explorer"));
11 return resolve(msg("Reveal in Files"));
13​
14export function revealInFileExplorerLabelForOs(
15 os: ExecutionEnvironmentPlatformOs,
16 resolve: MessageResolver = m,
17): string {
18 if (os === "darwin") return resolve(msg("Reveal in Finder"));
19 if (os === "windows") return resolve(msg("Reveal in File Explorer"));
20 return resolve(msg("Reveal in Files"));
22​
23export function revealInFileExplorerLabelForKind(
24 kind: FileManagerRevealKind,
25 resolve: MessageResolver = m,
26): string {
27 if (kind === "finder") return resolve(msg("Reveal in Finder"));
28 if (kind === "file-explorer") return resolve(msg("Reveal in File Explorer"));
29 return resolve(msg("Reveal in Files"));