Skip to content

Conversation

@dmatos2012
Copy link

Closes #9266.

Big Note: I noticed that this worked properly under NixOS, but on my Ubuntu VM it didnt.

The reason is in src/build/GhosttyI18n.zig because the locale is expected in the <lang>_<region> without the encoding suffix. <lang>_<region>_<encoding>

        // There is no encoding suffix in the LC_MESSAGES path on FreeBSD,
        // so we need to remove it from `locale` to have a correct destination string.
        // (/usr/local/share/locale/en_AU/LC_MESSAGES)
        const target_locale = comptime if (builtin.target.os.tag == .freebsd)
            std.mem.trimRight(u8, locale, ".UTF-8")
        else
            locale;

If i force it to always trim the encoding it works, but I am guessing its there for a reason ,so maybe some of the maintainer can shed some light in the best way forward, as I am not an expert in how other systems deal with it. Here you see Open in Ghostty -> Abrir con Ghostty

image
  • I wanted to format the py file with ruff but didnt want to drown the changes, so maybe something that could be worth doing so that also our py files have std formatting.

Note

Used AI only for helping me debug where the locales could be and why was it not detected, but no code help whatsoever

@dmatos2012 dmatos2012 requested a review from a team as a code owner December 19, 2025 21:25
Copy link
Contributor

@swsnr swsnr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a member of the ghostty project, so please excuse me for leaving a review, but as the original author of this script (albeit for Wezterm originally), and being somewhat familiar with xgettext and Python, I'd like to leave two remarks concerning this pull request 🙂

import gettext

DOMAIN = "com.mitchellh.ghostty"
share_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
Copy link
Contributor

@swsnr swsnr Dec 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be more readable with pathlib:

from pathlib import Path

locale_dir = Path(__file__).absolute().parent.parent.parent / "locale"

And does the Ghostty build system even guarantee that the locales always end up at this path, relative to the nautilus extension directory?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll note that you can use .parents[2] instead of .parent.parent.parent =)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@trag1c Oh, thanks 🙏 I learn a new thing every day 🙂

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@swsnr As far as I can see, the nautilus extension is here
GhosttyResources

try steps.append(b.allocator, &b.addInstallFile(
       b.path("dist/linux/ghostty_nautilus.py"),
       "share/nautilus-python/extensions/ghostty.py",
   ).step);
   

and the locale is relative to share so share/locale/....

README

During the build process, each locale in `.po` files is compiled
into binary `.mo` files, stored under `share/locale/<LOCALE>/LC_MESSAGES/com.mitchellh.ghostty.mo`.
This can be directly accessed by `libintl`, which provide the various `gettext` 
....

The only issue is what I mentioned in the original comment where some other platforms put the locale with a different suffix and then it doesnt work, so it just fallbacks.

"-",
});
// Silences the "unknown extension" errors
_ = xgettext.captureStdErr();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that that's a good idea.

I believe the proper way to handle different types of sources with different flags in xgettext is to use separate xgettext invocations to extract messages into intermediate pot files, and then use a final xgettext invocation to merge the intermediate pot files into the final one.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah thanks, I have edited it now. Much cleaner this way.

@dmatos2012
Copy link
Author

@swsnr Even though it seems you are not an official maintainer, I saw emoji reactions by at least a maintainer, so I assume these changes were approved as well from them. I made those changes, lmk and thanks for the review!

@dmatos2012 dmatos2012 requested a review from swsnr January 22, 2026 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Localize the Nautilus extension

3 participants