mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
build: i18n should emit mo on every platform
This commit is contained in:
10
build.zig
10
build.zig
@ -82,6 +82,16 @@ pub fn build(b: *std.Build) !void {
|
|||||||
{
|
{
|
||||||
const run_cmd = b.addRunArtifact(exe.exe);
|
const run_cmd = b.addRunArtifact(exe.exe);
|
||||||
if (b.args) |args| run_cmd.addArgs(args);
|
if (b.args) |args| run_cmd.addArgs(args);
|
||||||
|
|
||||||
|
// Set the proper resources dir so things like shell integration
|
||||||
|
// work correctly. If we're running `zig build run` in Ghostty,
|
||||||
|
// this also ensures it overwrites the release one with our debug
|
||||||
|
// build.
|
||||||
|
run_cmd.setEnvironmentVariable(
|
||||||
|
"GHOSTTY_RESOURCES_DIR",
|
||||||
|
b.getInstallPath(.prefix, "share/ghostty"),
|
||||||
|
);
|
||||||
|
|
||||||
const run_step = b.step("run", "Run the app");
|
const run_step = b.step("run", "Run the app");
|
||||||
run_step.dependOn(&run_cmd.step);
|
run_step.dependOn(&run_cmd.step);
|
||||||
}
|
}
|
||||||
|
@ -18,23 +18,22 @@ steps: []*std.Build.Step,
|
|||||||
update_step: *std.Build.Step,
|
update_step: *std.Build.Step,
|
||||||
|
|
||||||
pub fn init(b: *std.Build, cfg: *const Config) !GhosttyI18n {
|
pub fn init(b: *std.Build, cfg: *const Config) !GhosttyI18n {
|
||||||
|
_ = cfg;
|
||||||
|
|
||||||
var steps = std.ArrayList(*std.Build.Step).init(b.allocator);
|
var steps = std.ArrayList(*std.Build.Step).init(b.allocator);
|
||||||
defer steps.deinit();
|
defer steps.deinit();
|
||||||
|
|
||||||
if (cfg.app_runtime == .gtk) {
|
inline for (locales) |locale| {
|
||||||
// Output the .mo files used by the GTK apprt
|
const msgfmt = b.addSystemCommand(&.{ "msgfmt", "-o", "-" });
|
||||||
inline for (locales) |locale| {
|
msgfmt.addFileArg(b.path("po/" ++ locale ++ ".po"));
|
||||||
const msgfmt = b.addSystemCommand(&.{ "msgfmt", "-o", "-" });
|
|
||||||
msgfmt.addFileArg(b.path("po/" ++ locale ++ ".po"));
|
|
||||||
|
|
||||||
try steps.append(&b.addInstallFile(
|
try steps.append(&b.addInstallFile(
|
||||||
msgfmt.captureStdOut(),
|
msgfmt.captureStdOut(),
|
||||||
std.fmt.comptimePrint(
|
std.fmt.comptimePrint(
|
||||||
"share/locale/{s}/LC_MESSAGES/{s}.mo",
|
"share/locale/{s}/LC_MESSAGES/{s}.mo",
|
||||||
.{ locale, domain },
|
.{ locale, domain },
|
||||||
),
|
),
|
||||||
).step);
|
).step);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return .{
|
return .{
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const build_config = @import("../build_config.zig");
|
const build_config = @import("../build_config.zig");
|
||||||
|
|
||||||
|
const log = std.log.scoped(.i18n);
|
||||||
|
|
||||||
pub const InitError = error{
|
pub const InitError = error{
|
||||||
InvalidResourcesDir,
|
InvalidResourcesDir,
|
||||||
OutOfMemory,
|
OutOfMemory,
|
||||||
@ -26,6 +28,7 @@ pub fn init(resources_dir: []const u8) InitError!void {
|
|||||||
return error.OutOfMemory;
|
return error.OutOfMemory;
|
||||||
|
|
||||||
// Bind our bundle ID to the given locale path
|
// Bind our bundle ID to the given locale path
|
||||||
|
log.debug("binding domain={s} path={s}", .{ build_config.bundle_id, path });
|
||||||
_ = bindtextdomain(build_config.bundle_id, path.ptr) orelse
|
_ = bindtextdomain(build_config.bundle_id, path.ptr) orelse
|
||||||
return error.OutOfMemory;
|
return error.OutOfMemory;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user