Skip to content

Commit

Permalink
build: allow users to disable gettext support (--disable-nls)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuj authored and raveit65 committed Feb 5, 2021
1 parent afd8f48 commit 8a65321
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 7 deletions.
6 changes: 5 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}

if USE_NLS
PO_SUBDIR = po
endif

if ENABLE_JPEG
jpeg_DIRS = jpegutils
endif

SUBDIRS = po $(jpeg_DIRS) cut-n-paste src man plugins help data doc
SUBDIRS = $(PO_SUBDIR) $(jpeg_DIRS) cut-n-paste src man plugins help data doc

if ENABLE_THUMBNAILER
SUBDIRS += thumbnailer
Expand Down
13 changes: 7 additions & 6 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ GTK_DOC_CHECK(1.9)

AC_CHECK_FUNCS(strptime)

GETTEXT_PACKAGE=AC_PACKAGE_NAME
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Gettext package.])

# ****************************************************************
# Support for nl_langinfo (_NL_MEASUREMENT_MEASUREMENT) (optional)
# ****************************************************************
Expand All @@ -62,13 +66,9 @@ fi
# ***********
# Translation
# ***********
AM_GNU_GETTEXT_VERSION([0.19.8])
AM_GNU_GETTEXT_REQUIRE_VERSION([0.19.8])
AM_GNU_GETTEXT([external])

GETTEXT_PACKAGE=AC_PACKAGE_NAME
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Gettext package.])
AM_GNU_GETTEXT_VERSION([0.19.8])
AM_CONDITIONAL([USE_NLS], [test "x${USE_NLS}" = "xyes"])

AC_SUBST(CFLAGS)
AC_SUBST(LDFLAGS)
Expand Down Expand Up @@ -429,5 +429,6 @@ Configure summary:
RSVG support ...............: ${have_rsvg}
Colour management support ..: ${have_lcms}
GObject Introspection.......: ${have_introspection}
Gettext support.............: ${USE_NLS}
Thumbnailer.................: ${eom_thumbnailer}
"
10 changes: 10 additions & 0 deletions data/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,25 @@ desktopdir = $(datadir)/applications
desktop_DATA = eom.desktop
desktop_in_files = $(desktop_DATA:.desktop=.desktop.in)
desktop_in_in_files = $(desktop_in_files:.desktop.in=.desktop.in.in)

$(desktop_DATA): $(desktop_in_files)
if USE_NLS
$(AM_V_GEN) $(MSGFMT) --desktop --keyword= --keyword=Name --keyword=Comment --keyword=Keywords --template $< -d $(top_srcdir)/po -o $@
else
$(AM_V_GEN) cp $< $@
endif

appdatadir = $(datadir)/metainfo
appdata_DATA = eom.appdata.xml
appdata_in_files = $(appdata_DATA:.xml=.xml.in)
appdata_in_in_files = $(appdata_in_files:.xml.in=.xml.in.in)

$(appdata_DATA): $(appdata_in_files)
if USE_NLS
$(AM_V_GEN) $(MSGFMT) --xml --template $< -d $(top_srcdir)/po -o $@
else
$(AM_V_GEN) cp $< $@
endif

gsettings_ENUM_NAMESPACE = org.mate.eom
gsettings_ENUM_FILES = $(top_srcdir)/src/eom-scroll-view.h \
Expand Down
4 changes: 4 additions & 0 deletions help/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ HELP_MEDIA = \
figures/eom_start_window.png \
figures/eom_toolbar_editor_window.png

if USE_NLS
# Add linguas to be ignored, e.g. IGNORE_HELP_LINGUAS = ca de es fr
IGNORE_HELP_LINGUAS =
HELP_LINGUAS = $(if $(IGNORE_HELP_LINGUAS), \
$(filter-out $(IGNORE_HELP_LINGUAS),$(subst /,,$(dir $(wildcard */*.po)))), \
$(subst /,,$(dir $(wildcard */*.po))) )
else
HELP_LINGUAS =
endif

-include $(top_srcdir)/git.mk
4 changes: 4 additions & 0 deletions plugins/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ plugins_in_in_files = $(plugins_in_files:.desktop.in=.desktop.in.in)
plugins_DATA = $(plugins_in_files:.plugin.desktop.in=.plugin)

%.plugin: %.plugin.desktop.in
if USE_NLS
$(AM_V_GEN) $(MSGFMT) --desktop --keyword=Name --keyword=Description --template $< -d $(top_srcdir)/po -o $@
else
$(AM_V_GEN) cp $< $@
endif

DISTCLEANFILES = $(plugins_in_files)
CLEANFILES = $(plugins_DATA)
Expand Down
2 changes: 2 additions & 0 deletions plugins/reload/eom-reload-plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ eom_reload_plugin_activate (EomWindowActivatable *activatable)
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
plugin->ui_action_group = gtk_action_group_new ("EomReloadPluginActions");

#ifdef ENABLE_NLS
gtk_action_group_set_translation_domain (plugin->ui_action_group, GETTEXT_PACKAGE);
#endif /* ENABLE_NLS */

gtk_action_group_add_actions (plugin->ui_action_group, action_entries,
G_N_ELEMENTS (action_entries), plugin->window);
Expand Down
2 changes: 2 additions & 0 deletions src/eom-save-as-dialog-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ eom_save_as_dialog_new (GtkWindow *main, GList *images, GFile *base_file)
GtkWidget *label;

xml = gtk_builder_new_from_resource ("/org/mate/eom/ui/eom-multiple-save-as-dialog.ui");
#ifdef ENABLE_NLS
gtk_builder_set_translation_domain (xml, GETTEXT_PACKAGE);
#endif /* ENABLE_NLS */

dlg = GTK_WIDGET (g_object_ref (gtk_builder_get_object (xml, "eom_multiple_save_as_dialog")));
gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (main));
Expand Down
8 changes: 8 additions & 0 deletions src/eom-window.c
Original file line number Diff line number Diff line change
Expand Up @@ -4412,8 +4412,10 @@ eom_window_construct_ui (EomWindow *window)
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
priv->actions_window = gtk_action_group_new ("MenuActionsWindow");

#ifdef ENABLE_NLS
gtk_action_group_set_translation_domain (priv->actions_window,
GETTEXT_PACKAGE);
#endif /* ENABLE_NLS */

gtk_action_group_add_actions (priv->actions_window,
action_entries_window,
Expand All @@ -4430,8 +4432,10 @@ eom_window_construct_ui (EomWindow *window)

G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
priv->actions_image = gtk_action_group_new ("MenuActionsImage");
#ifdef ENABLE_NLS
gtk_action_group_set_translation_domain (priv->actions_image,
GETTEXT_PACKAGE);
#endif /* ENABLE_NLS */

gtk_action_group_add_actions (priv->actions_image,
action_entries_image,
Expand All @@ -4450,8 +4454,10 @@ eom_window_construct_ui (EomWindow *window)

G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
priv->actions_collection = gtk_action_group_new ("MenuActionsCollection");
#ifdef ENABLE_NLS
gtk_action_group_set_translation_domain (priv->actions_collection,
GETTEXT_PACKAGE);
#endif /* ENABLE_NLS */

gtk_action_group_add_actions (priv->actions_collection,
action_entries_collection,
Expand Down Expand Up @@ -4536,8 +4542,10 @@ eom_window_construct_ui (EomWindow *window)

G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
priv->actions_recent = gtk_action_group_new ("RecentFilesActions");
#ifdef ENABLE_NLS
gtk_action_group_set_translation_domain (priv->actions_recent,
GETTEXT_PACKAGE);
#endif /* ENABLE_NLS */
G_GNUC_END_IGNORE_DEPRECATIONS;

g_signal_connect (gtk_recent_manager_get_default (), "changed",
Expand Down
2 changes: 2 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,11 @@ main (int argc, char **argv)
GFile *css_file;
GtkCssProvider *provider;

#ifdef ENABLE_NLS
bindtextdomain (GETTEXT_PACKAGE, EOM_LOCALE_DIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
#endif /* ENABLE_NLS */

gdk_set_allowed_backends ("wayland,x11");

Expand Down

0 comments on commit 8a65321

Please sign in to comment.