diff options
| author | Leah Amelia Chen <hi@pluie.me> | 2025-08-06 14:44:40 +0800 |
|---|---|---|
| committer | Leah Amelia Chen <hi@pluie.me> | 2025-08-06 14:54:02 +0800 |
| commit | 5fbdb8c4591f0524130002c9097aa3e8c6df17fa (patch) | |
| tree | 0d85256a8b6ec090b011ce30558f8eae9fedf6b1 /src/os | |
| parent | c2165fc097689556c17102b095012a296f599945 (diff) | |
build: allow disabling i18n
GNU gettext simply is a PITA on certain platforms (i.e. Windows, musl
Linux, etc.) and currently it's not possible to cleanly remove i18n
from the build process, making building Ghostty on the aforementioned
platforms difficult. By providing users with a way to opt-out of the
i18n mechanisms (or opt-in, on platforms where i18n is disabled by
default) we can make sure that people at least have *some* way of
building Ghostty before i18n mechanisms can be integrated neatly.
Diffstat (limited to 'src/os')
| -rw-r--r-- | src/os/i18n.zig | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/os/i18n.zig b/src/os/i18n.zig index 2ecae27ac..69baf7a2c 100644 --- a/src/os/i18n.zig +++ b/src/os/i18n.zig @@ -73,6 +73,8 @@ pub const InitError = error{ /// want to set the domain for the entire application since this is also /// used by libghostty. pub fn init(resources_dir: []const u8) InitError!void { + if (comptime !build_config.i18n) return; + switch (builtin.os.tag) { // i18n is unsupported on Windows .windows => return, @@ -102,11 +104,13 @@ pub fn init(resources_dir: []const u8) InitError!void { /// This should only be called for apprts that are fully owning the /// Ghostty application. This should not be called for libghostty users. pub fn initGlobalDomain() error{OutOfMemory}!void { + if (comptime !build_config.i18n) return; _ = textdomain(build_config.bundle_id) orelse return error.OutOfMemory; } /// Translate a message for the Ghostty domain. pub fn _(msgid: [*:0]const u8) [*:0]const u8 { + if (comptime !build_config.i18n) return msgid; return dgettext(build_config.bundle_id, msgid); } @@ -132,6 +136,8 @@ pub fn canonicalizeLocale( buf: []u8, locale: []const u8, ) error{NoSpaceLeft}![:0]const u8 { + if (comptime !build_config.i18n) return locale; + // Fix zh locales for macOS if (fixZhLocale(locale)) |fixed| return fixed; |
