How to translate strings used in default GtkAboutDialog?

, ,

The default project created by Gnome Builder calls the function gtk_show_about_dialog setting the content by using properties.

The application I’m developping is supposed to be in Portuguese, but I can’t seem to find where to override these strings (such as the button labels: “About” and “Credits”, and others).

How can I do this? Is there a file to edit, or a configuration to change, or even some function I should call?

Actually everything should be already translated.

I get this launching LANGUAGE=pt_PT ./gtkabout
grafik

Source code:

/* Compile:
 * gcc $(pkg-config --cflags gtk+-3.0) -o gtkabout gtkabout.c $(pkg-config --libs gtk+-3.0) */
#include <gtk/gtk.h>

static void
show_about (GtkWidget *widget,
            gpointer   data)
{
  GtkWindow *parent = GTK_WINDOW (data);
  const gchar *authors[] = {"Me and Bobby McGee", NULL};
  gtk_show_about_dialog (parent,
                         "authors", authors,
                         NULL);
}

static void
activate (GtkApplication *app,
          gpointer        user_data)
{
  GtkWidget *window;
  GtkWidget *button;

  window = gtk_application_window_new (app);
  gtk_window_set_title (GTK_WINDOW (window), "Window");
  gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);

  button = gtk_button_new_with_label ("Show About Dialog");
  g_signal_connect (button, "clicked", G_CALLBACK (show_about), window);
  gtk_container_add (GTK_CONTAINER (window), button);
  gtk_widget_show_all (window);

  gtk_window_present (GTK_WINDOW (window));
}

int
main (int    argc,
      char **argv)
{
  GtkApplication *app;
  int status;

  app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
  g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
  status = g_application_run (G_APPLICATION (app), argc, argv);
  g_object_unref (app);

  return status;
}

Hello!
It should be translated but this is not the case.
I reported the same with Occitan and Amberol here:
https://gitlab.gnome.org/World/amberol/-/issues/217

Now that I saw these answers, I believe the difference lies in that your example is made to be compiled and executed as a native executable, but it seems that Gnome Builder does it through flatpak (and I can’t find how to change this), so maybe from the flatpak it only uses the “en_*” or the “C” locale.

I’ll try to set this env variable from Builder and see if it changes anything.

EDIT: No… nothing has changed. I tried to set both LANGUAGES and LANG and none made any difference.

I could reproduce this with the Flatpak version of @ebassi 's Amberol. Locale is de_AT, the 2 strings “About” and “Credits” are not translated:

grafik

However, if built from source, the 2 strings are translated:

grafik

So this seems to be Flatpak / runtime related.

1 Like

Thanks you, I feel less alone.

It’s very odd, because “About” and “Credits” come from the same place that translates the license identifier, and that one gets correctly localised.

This happens only in runtime 42 and everything is okay with the nightly runtime:

$ flatpak remote-add --if-not-exists gnome-nightly https://nightly.gnome.org/gnome-nightly.flatpakrepo
$ flatpak install gnome-nightly org.gnome.Platform
$ flatpak run --runtime-version=master io.bassi.Amberol

Probably fixed with this commit: https://gitlab.gnome.org/GNOME/gtk/-/commit/19fb336c398aaea851d8d991c9c804e89299ad0d

1 Like