Merge pot files

This commit is contained in:
David Matos
2026-01-22 12:00:53 +01:00
parent 4f0f464fb3
commit c755720e17
28 changed files with 1114 additions and 1084 deletions

View File

@@ -62,22 +62,16 @@ pub fn addStepDependencies(
fn createUpdateStep(b: *std.Build) !*std.Build.Step {
const xgettext = b.addSystemCommand(&.{
// We do not specify specific language since we
// currently need to support `blp` and `python`
// for localization
"xgettext",
"--language=C",
"--from-code=UTF-8",
"--add-comments=Translators",
"--keyword=_",
"--keyword=C_:1c,2",
"--package-name=" ++ domain,
"--msgid-bugs-address=m@mitchellh.com",
"--copyright-holder=\"Mitchell Hashimoto, Ghostty contributors\"",
"-o",
"-",
});
// Silences the "unknown extension" errors
_ = xgettext.captureStdErr();
// Collect to intermediate .pot file
xgettext.addArg("-o");
const gtk_pot = xgettext.addOutputFileArg("gtk.pot");
// Not cacheable due to the gresource files
xgettext.has_side_effects = true;
@@ -96,11 +90,6 @@ fn createUpdateStep(b: *std.Build) !*std.Build.Step {
xgettext.addFileInput(b.path(path));
}
// Add suport for localizing our `nautilus` integration
const nautilus_script_path = "dist/linux/ghostty_nautilus.py";
xgettext.addArg(nautilus_script_path);
xgettext.addFileInput(b.path(nautilus_script_path));
{
// Iterate over all of the files underneath `src/apprt/gtk`. We store
// them in an array so that they can be sorted into a determininistic
@@ -158,16 +147,46 @@ fn createUpdateStep(b: *std.Build) !*std.Build.Step {
}
}
// Add suport for localizing our `nautilus` integration
const xgettext_py = b.addSystemCommand(&.{
"xgettext",
"--language=Python",
"--from-code=UTF-8",
});
// Collect to intermediate .pot file
xgettext_py.addArg("-o");
const py_pot = xgettext_py.addOutputFileArg("py.pot");
const nautilus_script_path = "dist/linux/ghostty_nautilus.py";
xgettext_py.addArg(nautilus_script_path);
xgettext_py.addFileInput(b.path(nautilus_script_path));
// Merge pot files
const xgettext_merge = b.addSystemCommand(&.{
"xgettext",
"--add-comments=Translators",
"--package-name=" ++ domain,
"--msgid-bugs-address=m@mitchellh.com",
"--copyright-holder=\"Mitchell Hashimoto, Ghostty contributors\"",
// msgcat would work but generates extra headers not needed?
"-o",
"-",
});
// py_pot needs to be first on merge order because of `xgettext` behavior around
// charset when merging the two `.pot` files
xgettext_merge.addFileArg(py_pot);
xgettext_merge.addFileArg(gtk_pot);
const usf = b.addUpdateSourceFiles();
usf.addCopyFileToSource(
xgettext.captureStdOut(),
xgettext_merge.captureStdOut(),
"po/" ++ domain ++ ".pot",
);
inline for (locales) |locale| {
const msgmerge = b.addSystemCommand(&.{ "msgmerge", "--quiet", "--no-fuzzy-matching" });
msgmerge.addFileArg(b.path("po/" ++ locale ++ ".po"));
msgmerge.addFileArg(xgettext.captureStdOut());
msgmerge.addFileArg(xgettext_merge.captureStdOut());
usf.addCopyFileToSource(msgmerge.captureStdOut(), "po/" ++ locale ++ ".po");
}