mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-12-31 18:52:12 +00:00
Sets the LANGUAGE environment variable based on the preferred languages as reported by NSLocale. macOS has a concept of preferred languages separate from the system locale. The set of preferred languages is a list in priority order of what translations the user prefers. A user can have, for example, "fr_FR" as their locale but "en" as their preferred language. This would mean that they want to use French units, date formats, etc. but they prefer English translations. gettext uses the LANGUAGE environment variable to override only translations and a priority order can be specified by separating the languages with colons. For example, "en:fr" would mean that English translations are preferred but if they are not available then French translations should be used. To further complicate things, Apple reports the languages in BCP-47 format which is not compatible with gettext's POSIX locale format so we have to canonicalize them. To canonicalize the languages we use an internal function from libintl. This isn't normally available but since we compile from source on macOS we can use it. This isn't necessary for other platforms.
59 lines
2.1 KiB
Zig
59 lines
2.1 KiB
Zig
//! The "os" package contains utilities for interfacing with the operating
|
|
//! system. These aren't restricted to syscalls or low-level operations, but
|
|
//! also OS-specific features and conventions.
|
|
|
|
const desktop = @import("desktop.zig");
|
|
const env = @import("env.zig");
|
|
const file = @import("file.zig");
|
|
const flatpak = @import("flatpak.zig");
|
|
const homedir = @import("homedir.zig");
|
|
const locale = @import("locale.zig");
|
|
const mouse = @import("mouse.zig");
|
|
const openpkg = @import("open.zig");
|
|
const pipepkg = @import("pipe.zig");
|
|
const resourcesdir = @import("resourcesdir.zig");
|
|
|
|
// Namespaces
|
|
pub const args = @import("args.zig");
|
|
pub const cgroup = @import("cgroup.zig");
|
|
pub const hostname = @import("hostname.zig");
|
|
pub const i18n = @import("i18n.zig");
|
|
pub const passwd = @import("passwd.zig");
|
|
pub const xdg = @import("xdg.zig");
|
|
pub const windows = @import("windows.zig");
|
|
pub const macos = @import("macos.zig");
|
|
pub const shell = @import("shell.zig");
|
|
|
|
// Functions and types
|
|
pub const CFReleaseThread = @import("cf_release_thread.zig");
|
|
pub const TempDir = @import("TempDir.zig");
|
|
pub const getEnvMap = env.getEnvMap;
|
|
pub const appendEnv = env.appendEnv;
|
|
pub const appendEnvAlways = env.appendEnvAlways;
|
|
pub const prependEnv = env.prependEnv;
|
|
pub const getenv = env.getenv;
|
|
pub const setenv = env.setenv;
|
|
pub const unsetenv = env.unsetenv;
|
|
pub const launchedFromDesktop = desktop.launchedFromDesktop;
|
|
pub const desktopEnvironment = desktop.desktopEnvironment;
|
|
pub const rlimit = file.rlimit;
|
|
pub const fixMaxFiles = file.fixMaxFiles;
|
|
pub const restoreMaxFiles = file.restoreMaxFiles;
|
|
pub const allocTmpDir = file.allocTmpDir;
|
|
pub const freeTmpDir = file.freeTmpDir;
|
|
pub const isFlatpak = flatpak.isFlatpak;
|
|
pub const FlatpakHostCommand = flatpak.FlatpakHostCommand;
|
|
pub const home = homedir.home;
|
|
pub const expandHome = homedir.expandHome;
|
|
pub const ensureLocale = locale.ensureLocale;
|
|
pub const clickInterval = mouse.clickInterval;
|
|
pub const open = openpkg.open;
|
|
pub const OpenType = openpkg.Type;
|
|
pub const pipe = pipepkg.pipe;
|
|
pub const resourcesDir = resourcesdir.resourcesDir;
|
|
pub const ShellEscapeWriter = shell.ShellEscapeWriter;
|
|
|
|
test {
|
|
_ = i18n;
|
|
}
|