i18n: allow localization of config diagnostics

This commit is contained in:
Jeffrey C. Ollie
2025-03-20 16:40:01 -05:00
parent 1980f9aed4
commit 8048473ebf
7 changed files with 237 additions and 56 deletions

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: com.mitchellh.ghostty\n" "Project-Id-Version: com.mitchellh.ghostty\n"
"Report-Msgid-Bugs-To: m@mitchellh.com\n" "Report-Msgid-Bugs-To: m@mitchellh.com\n"
"POT-Creation-Date: 2025-03-19 08:28-0700\n" "POT-Creation-Date: 2025-03-20 16:33-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -193,14 +193,6 @@ msgid ""
"commands may be executed." "commands may be executed."
msgstr "" msgstr ""
#: src/apprt/gtk/inspector.zig:144
msgid "Ghostty: Terminal Inspector"
msgstr ""
#: src/apprt/gtk/Surface.zig:1243
msgid "Copied to clipboard"
msgstr ""
#: src/apprt/gtk/CloseDialog.zig:47 #: src/apprt/gtk/CloseDialog.zig:47
msgid "Close" msgid "Close"
msgstr "" msgstr ""
@ -237,6 +229,14 @@ msgstr ""
msgid "The currently running process in this split will be terminated." msgid "The currently running process in this split will be terminated."
msgstr "" msgstr ""
#: src/apprt/gtk/inspector.zig:144
msgid "Ghostty: Terminal Inspector"
msgstr ""
#: src/apprt/gtk/Surface.zig:1243
msgid "Copied to clipboard"
msgstr ""
#: src/apprt/gtk/Window.zig:200 #: src/apprt/gtk/Window.zig:200
msgid "Main Menu" msgid "Main Menu"
msgstr "" msgstr ""
@ -257,3 +257,43 @@ msgstr ""
#: src/apprt/gtk/Window.zig:941 #: src/apprt/gtk/Window.zig:941
msgid "Ghostty Developers" msgid "Ghostty Developers"
msgstr "" msgstr ""
#: src/cli/args.zig:133
msgid "invalid field"
msgstr ""
#: src/cli/args.zig:161
msgid "unknown field"
msgstr ""
#: src/cli/args.zig:163 src/cli/args.zig:191
msgid "value required"
msgstr ""
#: src/cli/args.zig:165 src/cli/args.zig:206
msgid "invalid value"
msgstr ""
#: src/cli/args.zig:169
msgid "unknown error"
msgstr ""
#: src/cli/args.zig:218
msgid ", valid values are: "
msgstr ""
#: src/config/Config.zig:2722
msgid "cycle detected"
msgstr ""
#: src/config/Config.zig:2737
msgid "error opening"
msgstr ""
#: src/config/Config.zig:2758
msgid "not reading because file type is"
msgstr ""
#: src/config/Config.zig:3176
msgid "missing command after"
msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: com.mitchellh.ghostty\n" "Project-Id-Version: com.mitchellh.ghostty\n"
"Report-Msgid-Bugs-To: m@mitchellh.com\n" "Report-Msgid-Bugs-To: m@mitchellh.com\n"
"POT-Creation-Date: 2025-03-19 08:28-0700\n" "POT-Creation-Date: 2025-03-20 16:33-0500\n"
"PO-Revision-Date: 2025-03-06 14:57+0100\n" "PO-Revision-Date: 2025-03-06 14:57+0100\n"
"Last-Translator: Robin <r@rpfaeffle.com>\n" "Last-Translator: Robin <r@rpfaeffle.com>\n"
"Language-Team: German <translation-team-de@lists.sourceforge.net>\n" "Language-Team: German <translation-team-de@lists.sourceforge.net>\n"
@ -200,14 +200,6 @@ msgstr ""
"Diesen Text in das Terminal einzufügen könnte möglicherweise gefährlich " "Diesen Text in das Terminal einzufügen könnte möglicherweise gefährlich "
"sein. Es scheint, dass Anweisungen ausgeführt werden könnten." "sein. Es scheint, dass Anweisungen ausgeführt werden könnten."
#: src/apprt/gtk/inspector.zig:144
msgid "Ghostty: Terminal Inspector"
msgstr ""
#: src/apprt/gtk/Surface.zig:1243
msgid "Copied to clipboard"
msgstr "In die Zwischenablage kopiert"
#: src/apprt/gtk/CloseDialog.zig:47 #: src/apprt/gtk/CloseDialog.zig:47
msgid "Close" msgid "Close"
msgstr "Schließen" msgstr "Schließen"
@ -244,6 +236,14 @@ msgstr "Alle Terminalsitzungen in diesem Tab werden beendet."
msgid "The currently running process in this split will be terminated." msgid "The currently running process in this split will be terminated."
msgstr "Der aktuell laufende Prozess in diesem geteilten Fenster wird beendet." msgstr "Der aktuell laufende Prozess in diesem geteilten Fenster wird beendet."
#: src/apprt/gtk/inspector.zig:144
msgid "Ghostty: Terminal Inspector"
msgstr ""
#: src/apprt/gtk/Surface.zig:1243
msgid "Copied to clipboard"
msgstr "In die Zwischenablage kopiert"
#: src/apprt/gtk/Window.zig:200 #: src/apprt/gtk/Window.zig:200
msgid "Main Menu" msgid "Main Menu"
msgstr "Hauptmenü" msgstr "Hauptmenü"
@ -266,3 +266,43 @@ msgstr "Konfiguration wurde neu geladen"
#: src/apprt/gtk/Window.zig:941 #: src/apprt/gtk/Window.zig:941
msgid "Ghostty Developers" msgid "Ghostty Developers"
msgstr "Ghostty-Entwickler" msgstr "Ghostty-Entwickler"
#: src/cli/args.zig:133
msgid "invalid field"
msgstr ""
#: src/cli/args.zig:161
msgid "unknown field"
msgstr ""
#: src/cli/args.zig:163 src/cli/args.zig:191
msgid "value required"
msgstr ""
#: src/cli/args.zig:165 src/cli/args.zig:206
msgid "invalid value"
msgstr ""
#: src/cli/args.zig:169
msgid "unknown error"
msgstr ""
#: src/cli/args.zig:218
msgid ", valid values are: "
msgstr ""
#: src/config/Config.zig:2722
msgid "cycle detected"
msgstr ""
#: src/config/Config.zig:2737
msgid "error opening"
msgstr ""
#: src/config/Config.zig:2758
msgid "not reading because file type is"
msgstr ""
#: src/config/Config.zig:3176
msgid "missing command after"
msgstr ""

View File

@ -9,7 +9,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: com.mitchellh.ghostty\n" "Project-Id-Version: com.mitchellh.ghostty\n"
"Report-Msgid-Bugs-To: m@mitchellh.com\n" "Report-Msgid-Bugs-To: m@mitchellh.com\n"
"POT-Creation-Date: 2025-03-19 08:28-0700\n" "POT-Creation-Date: 2025-03-20 16:33-0500\n"
"PO-Revision-Date: 2025-03-19 09:52+0100\n" "PO-Revision-Date: 2025-03-19 09:52+0100\n"
"Last-Translator: Christoffer Tønnessen <christoffer@cto.gg>\n" "Last-Translator: Christoffer Tønnessen <christoffer@cto.gg>\n"
"Language-Team: Norwegian Bokmal <l10n-no@lister.huftis.org>\n" "Language-Team: Norwegian Bokmal <l10n-no@lister.huftis.org>\n"
@ -45,8 +45,8 @@ msgid ""
"One or more configuration errors were found. Please review the errors below, " "One or more configuration errors were found. Please review the errors below, "
"and either reload your configuration or ignore these errors." "and either reload your configuration or ignore these errors."
msgstr "" msgstr ""
"Én eller flere konfigurasjonsfeil ble funnet. Vennligst gjennomgå feilene under, " "Én eller flere konfigurasjonsfeil ble funnet. Vennligst gjennomgå feilene "
"og enten last konfigurasjonen din på nytt eller ignorer disse feilene." "under, og enten last konfigurasjonen din på nytt eller ignorer disse feilene."
#: src/apprt/gtk/ui/1.5/config-errors-dialog.blp:9 #: src/apprt/gtk/ui/1.5/config-errors-dialog.blp:9
msgid "Ignore" msgid "Ignore"
@ -203,14 +203,6 @@ msgstr ""
"Det ser ut som at kommandoer vil bli kjørt hvis du limer inn dette, vurder " "Det ser ut som at kommandoer vil bli kjørt hvis du limer inn dette, vurder "
"om du mener det er trygt." "om du mener det er trygt."
#: src/apprt/gtk/inspector.zig:144
msgid "Ghostty: Terminal Inspector"
msgstr "Ghostty: Terminalinspektør"
#: src/apprt/gtk/Surface.zig:1243
msgid "Copied to clipboard"
msgstr "Kopiert til utklippstavle"
#: src/apprt/gtk/CloseDialog.zig:47 #: src/apprt/gtk/CloseDialog.zig:47
msgid "Close" msgid "Close"
msgstr "Lukk" msgstr "Lukk"
@ -247,6 +239,14 @@ msgstr "Alle terminaløkter i denne fanen vil bli avsluttet."
msgid "The currently running process in this split will be terminated." msgid "The currently running process in this split will be terminated."
msgstr "Den kjørende prosessen for denne splitten vil bli avsluttet." msgstr "Den kjørende prosessen for denne splitten vil bli avsluttet."
#: src/apprt/gtk/inspector.zig:144
msgid "Ghostty: Terminal Inspector"
msgstr "Ghostty: Terminalinspektør"
#: src/apprt/gtk/Surface.zig:1243
msgid "Copied to clipboard"
msgstr "Kopiert til utklippstavle"
#: src/apprt/gtk/Window.zig:200 #: src/apprt/gtk/Window.zig:200
msgid "Main Menu" msgid "Main Menu"
msgstr "Hovedmeny" msgstr "Hovedmeny"
@ -267,3 +267,43 @@ msgstr "Konfigurasjonen ble lastet på nytt"
#: src/apprt/gtk/Window.zig:941 #: src/apprt/gtk/Window.zig:941
msgid "Ghostty Developers" msgid "Ghostty Developers"
msgstr "Ghostty-utviklere" msgstr "Ghostty-utviklere"
#: src/cli/args.zig:133
msgid "invalid field"
msgstr ""
#: src/cli/args.zig:161
msgid "unknown field"
msgstr ""
#: src/cli/args.zig:163 src/cli/args.zig:191
msgid "value required"
msgstr ""
#: src/cli/args.zig:165 src/cli/args.zig:206
msgid "invalid value"
msgstr ""
#: src/cli/args.zig:169
msgid "unknown error"
msgstr ""
#: src/cli/args.zig:218
msgid ", valid values are: "
msgstr ""
#: src/config/Config.zig:2722
msgid "cycle detected"
msgstr ""
#: src/config/Config.zig:2737
msgid "error opening"
msgstr ""
#: src/config/Config.zig:2758
msgid "not reading because file type is"
msgstr ""
#: src/config/Config.zig:3176
msgid "missing command after"
msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: com.mitchellh.ghostty\n" "Project-Id-Version: com.mitchellh.ghostty\n"
"Report-Msgid-Bugs-To: m@mitchellh.com\n" "Report-Msgid-Bugs-To: m@mitchellh.com\n"
"POT-Creation-Date: 2025-03-19 08:28-0700\n" "POT-Creation-Date: 2025-03-20 16:33-0500\n"
"PO-Revision-Date: 2025-02-27 09:16+0100\n" "PO-Revision-Date: 2025-02-27 09:16+0100\n"
"Last-Translator: Leah <hi@pluie.me>\n" "Last-Translator: Leah <hi@pluie.me>\n"
"Language-Team: Chinese (simplified) <i18n-zh@googlegroups.com>\n" "Language-Team: Chinese (simplified) <i18n-zh@googlegroups.com>\n"
@ -194,14 +194,6 @@ msgid ""
"commands may be executed." "commands may be executed."
msgstr "将以下内容粘贴至终端内将可能执行有害命令。" msgstr "将以下内容粘贴至终端内将可能执行有害命令。"
#: src/apprt/gtk/inspector.zig:144
msgid "Ghostty: Terminal Inspector"
msgstr "Ghostty 终端检视器"
#: src/apprt/gtk/Surface.zig:1243
msgid "Copied to clipboard"
msgstr "已复制至剪切板"
#: src/apprt/gtk/CloseDialog.zig:47 #: src/apprt/gtk/CloseDialog.zig:47
msgid "Close" msgid "Close"
msgstr "关闭" msgstr "关闭"
@ -238,6 +230,14 @@ msgstr "标签页内所有运行中的进程将被终止。"
msgid "The currently running process in this split will be terminated." msgid "The currently running process in this split will be terminated."
msgstr "分屏内正在运行中的进程将被终止。" msgstr "分屏内正在运行中的进程将被终止。"
#: src/apprt/gtk/inspector.zig:144
msgid "Ghostty: Terminal Inspector"
msgstr "Ghostty 终端检视器"
#: src/apprt/gtk/Surface.zig:1243
msgid "Copied to clipboard"
msgstr "已复制至剪切板"
#: src/apprt/gtk/Window.zig:200 #: src/apprt/gtk/Window.zig:200
msgid "Main Menu" msgid "Main Menu"
msgstr "主菜单" msgstr "主菜单"
@ -258,3 +258,43 @@ msgstr "已重新加载设置"
#: src/apprt/gtk/Window.zig:941 #: src/apprt/gtk/Window.zig:941
msgid "Ghostty Developers" msgid "Ghostty Developers"
msgstr "Ghostty 开发团队" msgstr "Ghostty 开发团队"
#: src/cli/args.zig:133
msgid "invalid field"
msgstr ""
#: src/cli/args.zig:161
msgid "unknown field"
msgstr ""
#: src/cli/args.zig:163 src/cli/args.zig:191
msgid "value required"
msgstr ""
#: src/cli/args.zig:165 src/cli/args.zig:206
msgid "invalid value"
msgstr ""
#: src/cli/args.zig:169
msgid "unknown error"
msgstr ""
#: src/cli/args.zig:218
msgid ", valid values are: "
msgstr ""
#: src/config/Config.zig:2722
msgid "cycle detected"
msgstr ""
#: src/config/Config.zig:2737
msgid "error opening"
msgstr ""
#: src/config/Config.zig:2758
msgid "not reading because file type is"
msgstr ""
#: src/config/Config.zig:3176
msgid "missing command after"
msgstr ""

View File

@ -93,7 +93,20 @@ fn createUpdateStep(b: *std.Build) !*std.Build.Step {
else => continue, else => continue,
} }
xgettext.addArg((b.pathJoin(&.{ "src/apprt/gtk", src.path }))); const path = b.pathJoin(&.{ "src/apprt/gtk", src.path });
xgettext.addArg(path);
xgettext.addFileInput(b.path(path));
}
}
{
const other_files = [_][]const u8{
"src/cli/args.zig",
"src/config/Config.zig",
};
for (other_files) |path| {
xgettext.addArg(path);
xgettext.addFileInput(b.path(path));
} }
} }

View File

@ -7,6 +7,7 @@ const diags = @import("diagnostics.zig");
const internal_os = @import("../os/main.zig"); const internal_os = @import("../os/main.zig");
const Diagnostic = diags.Diagnostic; const Diagnostic = diags.Diagnostic;
const DiagnosticList = diags.DiagnosticList; const DiagnosticList = diags.DiagnosticList;
const i18n = internal_os.i18n;
const log = std.log.scoped(.cli); const log = std.log.scoped(.cli);
@ -129,7 +130,7 @@ pub fn parse(
// Add our diagnostic // Add our diagnostic
try dst._diagnostics.append(arena_alloc, .{ try dst._diagnostics.append(arena_alloc, .{
.key = try arena_alloc.dupeZ(u8, arg), .key = try arena_alloc.dupeZ(u8, arg),
.message = "invalid field", .message = std.mem.span(i18n._("invalid field")),
.location = try diags.Location.fromIter(iter, arena_alloc), .location = try diags.Location.fromIter(iter, arena_alloc),
}); });
@ -157,13 +158,15 @@ pub fn parse(
// OOM is not recoverable since we need to allocate to // OOM is not recoverable since we need to allocate to
// track more error messages. // track more error messages.
error.OutOfMemory => return err, error.OutOfMemory => return err,
error.InvalidField => "unknown field", error.InvalidField => std.mem.span(i18n._("unknown field")),
error.ValueRequired => formatValueRequired(T, arena_alloc, key) catch "value required", error.ValueRequired => formatValueRequired(T, arena_alloc, key) catch
error.InvalidValue => formatInvalidValue(T, arena_alloc, key, value) catch "invalid value", std.mem.span(i18n._("value required")),
error.InvalidValue => formatInvalidValue(T, arena_alloc, key, value) catch
std.mem.span(i18n._("invalid value")),
else => try std.fmt.allocPrintZ( else => try std.fmt.allocPrintZ(
arena_alloc, arena_alloc,
"unknown error {}", "{s} {}",
.{err}, .{ i18n._("unknown error"), err },
), ),
}; };
@ -185,7 +188,7 @@ fn formatValueRequired(
var buf = std.ArrayList(u8).init(arena_alloc); var buf = std.ArrayList(u8).init(arena_alloc);
errdefer buf.deinit(); errdefer buf.deinit();
const writer = buf.writer(); const writer = buf.writer();
try writer.print("value required", .{}); try writer.writeAll(std.mem.span(i18n._("value required")));
try formatValues(T, key, writer); try formatValues(T, key, writer);
try writer.writeByte(0); try writer.writeByte(0);
return buf.items[0 .. buf.items.len - 1 :0]; return buf.items[0 .. buf.items.len - 1 :0];
@ -200,7 +203,7 @@ fn formatInvalidValue(
var buf = std.ArrayList(u8).init(arena_alloc); var buf = std.ArrayList(u8).init(arena_alloc);
errdefer buf.deinit(); errdefer buf.deinit();
const writer = buf.writer(); const writer = buf.writer();
try writer.print("invalid value \"{?s}\"", .{value}); try writer.print("{s} \"{?s}\"", .{ i18n._("invalid value"), value });
try formatValues(T, key, writer); try formatValues(T, key, writer);
try writer.writeByte(0); try writer.writeByte(0);
return buf.items[0 .. buf.items.len - 1 :0]; return buf.items[0 .. buf.items.len - 1 :0];
@ -212,7 +215,7 @@ fn formatValues(comptime T: type, key: []const u8, writer: anytype) std.mem.Allo
if (std.mem.eql(u8, key, f.name)) { if (std.mem.eql(u8, key, f.name)) {
switch (@typeInfo(f.type)) { switch (@typeInfo(f.type)) {
.@"enum" => |e| { .@"enum" => |e| {
try writer.print(", valid values are: ", .{}); try writer.writeAll(std.mem.span(i18n._(", valid values are: ")));
inline for (e.fields, 0..) |field, i| { inline for (e.fields, 0..) |field, i| {
if (i != 0) try writer.print(", ", .{}); if (i != 0) try writer.print(", ", .{});
try writer.print("{s}", .{field.name}); try writer.print("{s}", .{field.name});

View File

@ -23,6 +23,7 @@ const terminal = @import("../terminal/main.zig");
const internal_os = @import("../os/main.zig"); const internal_os = @import("../os/main.zig");
const cli = @import("../cli.zig"); const cli = @import("../cli.zig");
const Command = @import("../Command.zig"); const Command = @import("../Command.zig");
const i18n = internal_os.i18n;
const conditional = @import("conditional.zig"); const conditional = @import("conditional.zig");
const Conditional = conditional.Conditional; const Conditional = conditional.Conditional;
@ -2717,8 +2718,8 @@ pub fn loadRecursiveFiles(self: *Config, alloc_gpa: Allocator) !void {
const diag: cli.Diagnostic = .{ const diag: cli.Diagnostic = .{
.message = try std.fmt.allocPrintZ( .message = try std.fmt.allocPrintZ(
arena_alloc, arena_alloc,
"config-file {s}: cycle detected", "config-file {s}: {s}",
.{path}, .{ path, i18n._("cycle detected") },
), ),
}; };
@ -2732,8 +2733,8 @@ pub fn loadRecursiveFiles(self: *Config, alloc_gpa: Allocator) !void {
const diag: cli.Diagnostic = .{ const diag: cli.Diagnostic = .{
.message = try std.fmt.allocPrintZ( .message = try std.fmt.allocPrintZ(
arena_alloc, arena_alloc,
"error opening config-file {s}: {}", "{s} config-file {s}: {}",
.{ path, err }, .{ i18n._("error opening"), path, err },
), ),
}; };
@ -2751,8 +2752,12 @@ pub fn loadRecursiveFiles(self: *Config, alloc_gpa: Allocator) !void {
const diag: cli.Diagnostic = .{ const diag: cli.Diagnostic = .{
.message = try std.fmt.allocPrintZ( .message = try std.fmt.allocPrintZ(
arena_alloc, arena_alloc,
"config-file {s}: not reading because file type is {s}", "config-file {s}: {s} {s}",
.{ path, @tagName(kind) }, .{
path,
i18n._("not reading because file type is"),
@tagName(kind),
},
), ),
}; };
@ -3167,8 +3172,8 @@ pub fn parseManuallyHook(
.location = try cli.Location.fromIter(iter, alloc), .location = try cli.Location.fromIter(iter, alloc),
.message = try std.fmt.allocPrintZ( .message = try std.fmt.allocPrintZ(
alloc, alloc,
"missing command after {s}", "{s} {s}",
.{arg}, .{ i18n._("missing command after"), arg },
), ),
}); });