Skip to content

Commit

Permalink
Make the libadwaita change also work on macOS
Browse files Browse the repository at this point in the history
Same thing, the locales have to be packed so that it works without
Homebrew installed because apparently libadwaita also hardcodes the path
there (I suppose that it is hardcoded to /opt/homebrew/share/locale).
  • Loading branch information
danirod committed Aug 6, 2024
1 parent 11b50a4 commit ff2865e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions build-aux/macos-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ glib-compile-schemas "$RESOURCES_ROOT/share/glib-2.0/schemas"
gtk4-update-icon-cache -q -t -f "$RESOURCES_ROOT/share/icons/hicolor"
gtk4-update-icon-cache -q -t -f "$RESOURCES_ROOT/share/icons/Adwaita"

# Add extra locales
for lang in $(cat "po/LINGUAS" | grep -v '^#\|en'); do
cp -f $(brew --prefix)/share/locale/$lang/LC_MESSAGES/{gdk-pixbuf,gettext-runtime,glib20,gtk40,gtksourceview-5,libadwaita,shared-mime-info}.mo "$RESOURCES_ROOT/share/locale/$lang/LC_MESSAGES"
done

# Mangle bin directory
mv "$RESOURCES_ROOT/bin" "$APP_ROOT/Contents/MacOS"

Expand Down
9 changes: 5 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,11 @@ fn main() -> glib::ExitCode {
init_glib();
init_gio_resources();

// This is dirty, but because adw_init() calls bindtextdomain() and uses a hardcoded static path,
// I need to actually re-bind libadwaita against my own localedir on Windows so that it can use
// a path relative to the application executable again.
#[cfg(target_os = "windows")]
// This is dirty, but because adw_init() calls bindtextdomain() and uses a hardcoded static
// path, I need to actually re-bind libadwaita against my own localedir on platforms where the
// datadir is not fixed, so that it can use a path relative to the application executable
// again.
#[cfg(any(target_os = "windows", target_os = "macos"))]
{
adw::init().expect("Failed to initialize system runtimes");
let localedir = app_rel_path("share/locale");
Expand Down

0 comments on commit ff2865e

Please sign in to comment.