9753 Commits

Author SHA1 Message Date
Robin Pfäffle
2ef11fb65f translations(german): add missing warning indicator 2025-03-08 08:08:51 +01:00
Robin Pfäffle
d511b3601d translations: add German translation 2025-03-08 08:08:51 +01:00
Mitchell Hashimoto
e03e98e106 Groundwork for cross-platform i18n with libintl for libghostty/macOS (#6619)
This builds on @pluiedev's excellent #6004.

## Background: The macOS (and libghostty consumer) Plan

Broadly, the decision I've come to is that for cross-platform
translations (i.e. strings shared across libghostty), we will be using
gettext and libghostty will export helper methods to call those (e.g.
`ghostty_translate` in this PR for singular forms). To be clear, **this
only applies to strings owned by libghostty**. For application-level
strings such as macOS-specific menu items and so on, we still have
choice but will likely using native features.

The reason for this is because converting gettext translations (`po`) to
native formats (Xcode String Catalog, `.strings`/`.stringsdict`) is
nightmare level, in particular for plural forms. I don't see a robust
path to doing it. And if we don't convert and don't use gettext, then
translators would have to maintain an identical translation in multiple
locations. To make matters worse, the macOS translation formats require
Apple-tooling for now unless you want to edit raw JSON.

Leveraging gettext lets us share translations across platforms and take
advantage of proven tech.

## PR Contents

**`pkg/libintl` builds and statically links libintl for macOS.** macOS
doesn't ship libintl with the system while Linux generally does with
libc, so we need to build this ourselves. This makes gettext available
to macOS. libintl is LGPL and we remain in compliance with that despite
static linking because our build process is fully open source, so
downstream consumers can modify our build scripts to replace it if they
wanted to.

~~**`src/os/locale.zig` now sets the `LANGUAGE` environment variable on
macOS based on the app's preferred languages.** macOS lets you configure
the system locale separate from preferred language. We previously relied
solely on `NSLocale.currentLocale`, but this only represents the system
locale. We now also look at `NSLocale.preferredLanguages` (a list in
priority order) and if we support a given language we set `LANGUAGE` so
gettext translates properly. Notably, the above lets us debug
translations in Xcode by setting alternate languages for debug builds
only.~~ Removed this for a future PR since it was problematic.

**`build.zig` unconditionally builds binary `mo` files** since they're
required for all apprts now.

**The macOS app bundles the translation strings.** This includes our
GTK-specific translation strings but the size of these is so small it
isn't worth the complexity of splitting up into multiple `pot`s at this
time, I think.

**i18n APIs moved to `src/os` from `src/apprt/gtk`.** Since these are
now cross-platform/cross-apprt, they're a core API. The only notable
change here is that `_` now maps to `dgettext` and explicitly specifies
our domain so that it's library-friendly. The GTK apprt calls
`initGlobalDomain` so that blueprint translations still work.

## Next Steps

This PR is all groundwork. The macOS app doesn't leverage any of this
yet, although I've verified it all works (e.g. calling the
`ghostty_translate` API from Swift).

For next steps, we need to have a use case for cross-platform
translations and the first one I was looking at was configuration error
messages and other core strings.
2025-03-07 14:51:12 -08:00
Mitchell Hashimoto
dcb8440b52 os: remove the preferredLanguages lookup 2025-03-07 13:43:00 -08:00
Mitchell Hashimoto
7eddf98269 Fix typos 2025-03-07 13:42:00 -08:00
Mitchell Hashimoto
da731e6caa typo i81n -> i18n 2025-03-07 13:42:00 -08:00
Mitchell Hashimoto
79a9ddf66f build: pure libghostty builds need to build translations 2025-03-07 13:42:00 -08:00
Mitchell Hashimoto
e8a988f6d3 os: i18n unsupported on windows 2025-03-07 13:42:00 -08:00
Mitchell Hashimoto
c7681e8fd7 apprt/gtk: use the new global i18n API 2025-03-07 13:42:00 -08:00
Mitchell Hashimoto
cff092f4c6 nix: update hashes 2025-03-07 13:42:00 -08:00
Mitchell Hashimoto
3ebd5b839f update translating readme 2025-03-07 13:42:00 -08:00
Mitchell Hashimoto
be839cb681 update our gitattributes with new generated files 2025-03-07 13:42:00 -08:00
Mitchell Hashimoto
3c49bc5086 os: locale automatically sets LANGUAGE based on macOS preferred 2025-03-07 13:42:00 -08:00
Mitchell Hashimoto
edf619205c add ghostty_translate C API 2025-03-07 13:42:00 -08:00
Mitchell Hashimoto
238573d42e i18n: export proper _ function 2025-03-07 13:42:00 -08:00
Mitchell Hashimoto
4cf127a064 build: i18n should emit mo on every platform 2025-03-07 13:42:00 -08:00
Mitchell Hashimoto
e8c20b5501 pkg/libintl: fix missing symbols 2025-03-07 13:42:00 -08:00
Mitchell Hashimoto
cb8085ab72 global state initializes i18n 2025-03-07 13:42:00 -08:00
Mitchell Hashimoto
dd95f727ec build: add libintl for macOS builds 2025-03-07 13:41:59 -08:00
Mitchell Hashimoto
67488754d5 pkg/libintl 2025-03-07 13:41:59 -08:00
Leah Amelia Chen
4a215a9518 gtk: use AdwAlertDialog for close dialogs, fix incorrect close dialogs (#5741)
AdwAlertDialog is the recommended way to do alert/message dialogs
starting from libadwaita 1.5, and is much easier to manage than
GtkMessageDialog. (The latter is also deprecated since GTK 4.10, but
this PR does not migrate it to use GtkAlertDialog, mostly because of its
obtuse interface and that we'll remove the GtkMessageDialog code anyway
in 1.2 when we remove non-Adwaita builds.)

We also had two bugs where tabs with only one split would display the
"close surface" confirmation dialog, and windows would do the same when
closed via the "Close Window" menu item or by the `close_window` keybind
action. (The "close window" dialog only appears when the user clicks on
the close button on the titlebar.) Initially I was very confused by
this, but it turns out that we don't have any apprt action related to
closing a window, and it was simply closing surfaces...
2025-03-07 20:46:23 +01:00
Leah Amelia Chen
b25da6b9c4 core: update zig2nix to use explicit Zig version from Nix (#6617)
This will avoid build breakage in the near future as Zig 0.14 is coming
to Nix.
2025-03-07 20:42:13 +01:00
Jeffrey C. Ollie
3ba4864f6c core: update zig2nix to use explicit Zig version from Nix
This will avoid build breakage in the near future as Zig 0.14 is coming
to Nix.
2025-03-07 11:46:30 -06:00
Leah Amelia Chen
77e16770cc gtk: build gtk4-layer-shell ourselves (#6614)
As of now `gtk4-layer-shell` is unavailable on recent, stable releases
of many distros (Debian 12, Ubuntu 24.04, openSUSE Leap & Tumbleweed,
etc.) and outdated on many others (Nixpkgs 24.11/unstable, Fedora 41,
etc.) This is inconvenient for our users and severely limits where the
quick terminal can be used. As a result we then build gtk4-layer-shell
ourselves by default unless `--system` or `-fsys=gtk4-layer-shell` are
specified. This also allows me to add an idiomatic Zig API on top of the
library and avoiding adding even more raw C code in the GTK apprt.

Since we now build gtk4-layer-shell it should be theoretically available
on all Linux systems we target. As such, the `-Dgtk-layer-shell` build
option has been removed. This is somewhat of an experimental change as I
don't know if gtk4-layer-shell works perfectly across all distros, and
we can always add the option back if need be.
2025-03-07 18:19:49 +01:00
Leah Amelia Chen
cd442eb9e2 gtk: build gtk4-layer-shell ourselves
As of now `gtk4-layer-shell` is unavailable on recent, stable releases
of many distros (Debian 12, Ubuntu 24.04, openSUSE Leap & Tumbleweed, etc.)
and outdated on many others (Nixpkgs 24.11/unstable, Fedora 41, etc.)
This is inconvenient for our users and severely limits where the quick
terminal can be used. As a result we then build gtk4-layer-shell ourselves
by default unless `--system` or `-fsys=gtk4-layer-shell` are specified.
This also allows me to add an idiomatic Zig API on top of the library
and avoiding adding even more raw C code in the GTK apprt.

Since we now build gtk4-layer-shell it should be theoretically available
on all Linux systems we target. As such, the `-Dgtk-layer-shell` build
option has been removed. This is somewhat of an experimental change as
I don't know if gtk4-layer-shell works perfectly across all distros, and
we can always add the option back if need be.
2025-03-07 17:52:06 +01:00
Leah Amelia Chen
6c00c36d62 config: make quick-terminal-autohide=false on Linux (#6613)
See diff for explanation
2025-03-07 17:36:05 +01:00
Leah Amelia Chen
9ed76729ab gtk: add separate close_window apprt action
For *some* reason we have a binding for close_window but it merely closes
the surface and not the entire window. That is not only misleading but
also just wrong. Now we make a separate apprt action for close_window
that would make it show a close confirmation prompt identical to as if
the user had clicked the (X) button on the window titlebar.
2025-03-06 20:32:38 +01:00
Leah Amelia Chen
b4bfdb2c44 translation: update template & zh_CN strings 2025-03-06 20:32:30 +01:00
Leah Amelia Chen
23d2d4ec70 gtk: use AdwAlertDialog for close dialogs 2025-03-06 20:32:30 +01:00
Leah Amelia Chen
260a90cbf0 config: make quick-terminal-autohide=false on Linux
See diff for explanation
2025-03-06 12:38:23 +01:00
Leah Amelia Chen
e07b6fdf6b gtk: implement quick terminal slide & autohide (#6090) 2025-03-05 23:20:03 +01:00
Leah Amelia Chen
44d4990eb2 gtk: implement quick-terminal-autohide 2025-03-05 21:51:35 +01:00
Leah Amelia Chen
58b0434092 docs: update information about quick terminal support on Linux 2025-03-05 21:37:49 +01:00
Jeffrey C. Ollie
d6bd7b56b3 gtk: implement sensitive content reveal on paste confirmation (#6054)
Fixes https://github.com/ghostty-org/ghostty/issues/4947 for gtk
This PR implements the senstive content hiding when displaying the paste
confirmation dialog in secure input mode.

Following changes are implemented:
- in the blueprint for each dialog add a show/hide button that is not
visible by default, and a Revealer that is revealed by default
- save the `secure_input` action value for each surface in the GTK apprt
- pass the value when initializing the paste confirmation dialog
- in the dialog code, alter the visibility of the content and
reveal/hide buttons based on secure input flag value

Demo:


https://github.com/user-attachments/assets/c91cbd3d-ed3b-464d-b4cf-e51fe7aa23b7

I feel like this is already a nearly full implementation, but I'm
leaving this as a draft for now, since i need to look into blueprints
for Adwaita 1.2, and verify if it behaves properly when the dialog is in
not-sensitive input mode and in OSC52 mode.
2025-03-05 14:27:13 -06:00
Leah Amelia Chen
8f7425f78c gtk: implement quick terminal slide animation
Yet another protocol that as far as I know only KWin implements.
Oh well, might as well let KDE users such as myself enjoy it OOTB
2025-03-05 21:13:13 +01:00
Maciej Bartczak
bd617c52e9 code review:
- implement blueprints for Adwaita 1.2
- use postifx notation for casting gtk widgets
- fix formatting
2025-03-05 21:03:02 +01:00
Maciej Bartczak
f71b294697 gtk: new approach to reveal/hide buttons 2025-03-05 21:03:02 +01:00
Maciej Bartczak
7123d4e055 gtk: blur the content view instead of using a Revealer widget 2025-03-05 21:03:02 +01:00
Maciej Bartczak
1f695c2646 gtk: implement sensitive content reveal mechanism when showing paste confirmation in secure input mode 2025-03-05 21:02:58 +01:00
Jeffrey C. Ollie
58adaffcb9 gtk: don't modify horizontal alignment on menus that have arrows (#6087)
Setting the horizontal alignment to start on popover menus that have
arrows results in visual anomalies:


![image](https://github.com/user-attachments/assets/fef279a3-73cf-4717-9b32-605ccd48c934)

From Discord:

https://discord.com/channels/1005603569187160125/1346819853612482571
2025-03-05 13:42:50 -06:00
Jeffrey C. Ollie
8f62901218 gtk: don't modify horizontal alignment on menus that have arrows 2025-03-05 13:28:57 -06:00
Leah Amelia Chen
2f65f01fc8 gtk: add localization support, take 3 (#6004)
This is my third (!) attempt at implementing localization support. By
leveraging GTK builder to do most of the `gettext` calls, I can avoid
the whole mess about missing symbols on non-glibc platforms.

Added some documentation too for contributors and translators, just for
good measure.

Supersedes #5214, resolves the GTK half of #2357
2025-03-05 20:12:52 +01:00
Mitchell Hashimoto
66e8d91957 Make equalize_splits action only affect current window (#6080)
Fixes #6064 


https://github.com/user-attachments/assets/bbf393be-de98-41eb-aaad-3a185705ed4c
2025-03-04 07:36:00 -08:00
Ken VanDine
fd6e4fd615 fix: Generate pixbuf loader cache on start if needed, fixes #6066 (#6079)
This fix ensures the correct pixbuf loaders are used, not mixing in
libraries from the host.
2025-03-04 09:38:23 -05:00
Bryan Lee
423bc1971b Make equalize_splits action only affect current window 2025-03-04 22:37:32 +08:00
Ken VanDine
2c6e6ad680 fix: Generate pixbuf loader cache on start if needed, fixes #6066 2025-03-04 08:50:11 -05:00
Leah Amelia Chen
6373399e59 os: deprioritize GHOSTTY_RESOURCES_DIR for debug builds
When one develops Ghostty while using Ghostty it could lead to an
interesting conundrum: the freshly built Ghostty would use the parent
Ghostty's resources, which would be stale and not reflect any new
changes to resources. This is especially bad for translators, since
their translations would not be reflected in the newly built Ghostty
if they happen to run it under older Ghostty, which is not only
counterintuitive and also painful in terms of workflow.

Now, on debug builds we always try to use the terminfo detection method
first in order to locate the zig-out/share/ghostty folder, and only fall
back to GHOSTTY_RESOURCES_DIR if the executable is for some reason no
longer in zig-out. You can test this behavior by manually moving the
Ghostty executable out of zig-out, and then launching it with and without
Ghostty.
2025-03-03 10:19:58 +01:00
Mitchell Hashimoto
6b1a017a86 build: some style changes, namely we should create steps only in root 2025-03-03 10:19:58 +01:00
Leah Amelia Chen
e252932bde translations: add basic Chinese translation 2025-03-03 10:19:58 +01:00
Leah Amelia Chen
9c97084ad0 gtk: extract translations from Zig source code 2025-03-03 10:19:58 +01:00