fix: enable i18n on FreeBSD

This commit is contained in:
-k
2025-06-17 08:15:19 -04:00
committed by Mitchell Hashimoto
parent 780ee894d8
commit 16348549c4
3 changed files with 9 additions and 3 deletions

View File

@ -46,7 +46,7 @@ pub fn build(b: *std.Build) !void {
if (config.app_runtime != .none) {
exe.install();
resources.install();
if (builtin.target.os.tag != .freebsd) i18n.install();
i18n.install();
}
// Libghostty

View File

@ -1,6 +1,7 @@
const GhosttyI18n = @This();
const std = @import("std");
const builtin = @import("builtin");
const Config = @import("Config.zig");
const gresource = @import("../apprt/gtk/gresource.zig");
const internal_os = @import("../os/main.zig");
@ -21,6 +22,11 @@ pub fn init(b: *std.Build, cfg: *const Config) !GhosttyI18n {
defer steps.deinit();
inline for (internal_os.i18n.locales) |locale| {
const target_locale = comptime if (builtin.target.os.tag == .freebsd)
std.mem.trimRight(u8, locale, ".UTF-8")
else
locale;
const msgfmt = b.addSystemCommand(&.{ "msgfmt", "-o", "-" });
msgfmt.addFileArg(b.path("po/" ++ locale ++ ".po"));
@ -28,7 +34,7 @@ pub fn init(b: *std.Build, cfg: *const Config) !GhosttyI18n {
msgfmt.captureStdOut(),
std.fmt.comptimePrint(
"share/locale/{s}/LC_MESSAGES/{s}.mo",
.{ locale, domain },
.{ target_locale, domain },
),
).step);
}

View File

@ -70,7 +70,7 @@ pub const InitError = error{
pub fn init(resources_dir: []const u8) InitError!void {
// i18n is unsupported on Windows
switch (builtin.os.tag) {
.windows, .freebsd => return,
.windows => return,
else => {
// Our resources dir is always nested below the share dir that
// is standard for translations.