]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
Add support for translating the user visible strings in some themes
authorHans de Goede <hdegoede@redhat.com>
Tue, 26 Feb 2019 10:03:36 +0000 (11:03 +0100)
committerHans de Goede <hdegoede@redhat.com>
Tue, 26 Feb 2019 16:05:14 +0000 (17:05 +0100)
This commit adds initial translation support, for now translation support
is limited to the user visible strings in some splash plugins and themes,
the daemon and commandline utils output are left untranslated for now.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Makefile.am
configure.ac
po/LINGUAS [new file with mode: 0644]
po/Makevars [new file with mode: 0644]
po/POTFILES.in [new file with mode: 0644]
po/Rules-themes [new file with mode: 0644]
po/nl.po [new file with mode: 0644]
src/libply/Makefile.am
src/libply/ply-i18n.h [new file with mode: 0644]
src/main.c
src/plugins/splash/two-step/plugin.c

index cb6eedbd3a2588d02ef52abbfac056fd52329bfd..2d38de13b1757eb76e6dbd0b92a06d219c89e0aa 100644 (file)
@@ -1,4 +1,4 @@
-SUBDIRS = src themes images scripts systemd-units
+SUBDIRS = po src themes images scripts systemd-units
 
 if BUILD_DOCUMENTATION
 SUBDIRS += docs
@@ -6,7 +6,7 @@ endif
 
 DISTCHECK_CONFIGURE_FLAGS = --disable-tests --disable-systemd-integration
 
-EXTRA_DIST = ChangeLog                                                         \
+EXTRA_DIST = build-tools/config.rpath ChangeLog                                \
              README
 
 MAINTAINERCLEANFILES = aclocal.m4                                              \
@@ -15,3 +15,5 @@ MAINTAINERCLEANFILES = aclocal.m4                                              \
                        config.sub                                              \
                        configure                                               \
                        Makefile.in
+
+ACLOCAL_AMFLAGS = -I m4
index 78550d089d15922acf17c8ffe7ea1983e7d408b6..977102749bbfa1422f45286a96570b48161649b3 100644 (file)
@@ -15,6 +15,13 @@ AM_INIT_AUTOMAKE([dist-xz no-dist-gzip])
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 AM_MAINTAINER_MODE([enable])
 
+AM_GNU_GETTEXT_VERSION([0.19.8])
+AM_GNU_GETTEXT([external])
+AC_PATH_PROG([INTLTOOL_EXTRACT], [intltool-extract])
+if test x$INTLTOOL_EXTRACT = x; then
+  AC_MSG_ERROR([intltool-extract is required to build plymouth])
+fi
+
 PKG_PROG_PKG_CONFIG
 LT_INIT([dlopen disable-static pic-only])
 
@@ -286,7 +293,7 @@ AS_AC_EXPAND(PLYMOUTH_LIBDIR, $libdir)
 AS_AC_EXPAND(PLYMOUTH_LIBEXECDIR, $libexecdir)
 AS_AC_EXPAND(PLYMOUTH_DATADIR, $datadir)
 
-AC_CONFIG_FILES([Makefile
+AC_CONFIG_FILES([Makefile po/Makefile.in
            src/libply/Makefile
            src/libply-splash-core/Makefile
            src/libply-splash-graphics/Makefile
diff --git a/po/LINGUAS b/po/LINGUAS
new file mode 100644 (file)
index 0000000..bec81d2
--- /dev/null
@@ -0,0 +1 @@
+nl
diff --git a/po/Makevars b/po/Makevars
new file mode 100644 (file)
index 0000000..40e01c8
--- /dev/null
@@ -0,0 +1,78 @@
+# Makefile variables for PO directory in any package using GNU gettext.
+
+# Usually the message domain is the same as the package name.
+DOMAIN = $(PACKAGE)
+
+# These two variables depend on the location of this directory.
+subdir = po
+top_builddir = ..
+
+# These options get passed to xgettext.
+XGETTEXT_OPTIONS = --keyword=_ --keyword=N_
+
+# This is the copyright holder that gets inserted into the header of the
+# $(DOMAIN).pot file.  Set this to the copyright holder of the surrounding
+# package.  (Note that the msgstr strings, extracted from the package's
+# sources, belong to the copyright holder of the package.)  Translators are
+# expected to transfer the copyright for their translations to this person
+# or entity, or to disclaim their copyright.  The empty string stands for
+# the public domain; in this case the translators are expected to disclaim
+# their copyright.
+COPYRIGHT_HOLDER = Plymouth contributors
+
+# This tells whether or not to prepend "GNU " prefix to the package
+# name that gets inserted into the header of the $(DOMAIN).pot file.
+# Possible values are "yes", "no", or empty.  If it is empty, try to
+# detect it automatically by scanning the files in $(top_srcdir) for
+# "GNU packagename" string.
+PACKAGE_GNU = no
+
+# This is the email address or URL to which the translators shall report
+# bugs in the untranslated strings:
+# - Strings which are not entire sentences, see the maintainer guidelines
+#   in the GNU gettext documentation, section 'Preparing Strings'.
+# - Strings which use unclear terms or require additional context to be
+#   understood.
+# - Strings which make invalid assumptions about notation of date, time or
+#   money.
+# - Pluralisation problems.
+# - Incorrect English spelling.
+# - Incorrect formatting.
+# It can be your email address, or a mailing list address where translators
+# can write to without being subscribed, or the URL of a web page through
+# which the translators can contact you.
+MSGID_BUGS_ADDRESS =
+
+# This is the list of locale categories, beyond LC_MESSAGES, for which the
+# message catalogs shall be used.  It is usually empty.
+EXTRA_LOCALE_CATEGORIES =
+
+# This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
+# context.  Possible values are "yes" and "no".  Set this to yes if the
+# package uses functions taking also a message context, like pgettext(), or
+# if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
+USE_MSGCTXT = no
+
+# These options get passed to msgmerge.
+# Useful options are in particular:
+#   --previous            to keep previous msgids of translated messages,
+#   --quiet               to reduce the verbosity.
+MSGMERGE_OPTIONS =
+
+# These options get passed to msginit.
+# If you want to disable line wrapping when writing PO files, add
+# --no-wrap to MSGMERGE_OPTIONS, XGETTEXT_OPTIONS, and
+# MSGINIT_OPTIONS.
+MSGINIT_OPTIONS =
+
+# This tells whether or not to regenerate a PO file when $(DOMAIN).pot
+# has changed.  Possible values are "yes" and "no".  Set this to no if
+# the POT file is checked in the repository and the version control
+# program ignores timestamps.
+PO_DEPENDS_ON_POT = yes
+
+# This tells whether or not to forcibly update $(DOMAIN).pot and
+# regenerate PO files on "make dist".  Possible values are "yes" and
+# "no".  Set this to no if the POT file and PO files are maintained
+# externally.
+DIST_DEPENDS_ON_UPDATE_PO = yes
diff --git a/po/POTFILES.in b/po/POTFILES.in
new file mode 100644 (file)
index 0000000..bbce0ef
--- /dev/null
@@ -0,0 +1,9 @@
+# List of source files which contain translatable strings.
+
+# For now we only translate the user visible strings in some splash plugins
+# (the daemon and commandline utils output is untranslated for now)
+src/plugins/splash/two-step/plugin.c
+
+# Generated from the theme.in files by "intltool-extract --type=gettext/ini"
+themes/bgrt/bgrt.plymouth.in.h
+themes/spinner/spinner.plymouth.in.h
diff --git a/po/Rules-themes b/po/Rules-themes
new file mode 100644 (file)
index 0000000..8c7cbc9
--- /dev/null
@@ -0,0 +1,5 @@
+../themes/bgrt/bgrt.plymouth.in.h: ../themes/bgrt/bgrt.plymouth.in
+       intltool-extract --type=gettext/ini $<
+
+../themes/spinner/spinner.plymouth.in.h: ../themes/spinner/spinner.plymouth.in
+       intltool-extract --type=gettext/ini $<
diff --git a/po/nl.po b/po/nl.po
new file mode 100644 (file)
index 0000000..f730bce
--- /dev/null
+++ b/po/nl.po
@@ -0,0 +1,37 @@
+# Dutch translations for plymouth package
+# Nederlandse vertalingen voor het pakket plymouth.
+# Copyright (C) 2019 Plymouth contributors
+# This file is distributed under the same license as the plymouth package.
+# Hans de Goede <hdegoede@redhat.com>, 2019.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: plymouth 0.9.5\n"
+"Report-Msgid-Bugs-To: https://bugs.freedesktop.org/enter_bug.cgi?"
+"product=plymouth\n"
+"POT-Creation-Date: 2019-02-26 12:09+0100\n"
+"PO-Revision-Date: 2019-02-26 11:19+0100\n"
+"Last-Translator: Hans de Goede <hdegoede@redhat.com>\n"
+"Language-Team: Dutch\n"
+"Language: nl\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: src/plugins/splash/two-step/plugin.c:1809
+#, c-format
+msgid "%d%% complete"
+msgstr "%d%% voltooid"
+
+#: themes/bgrt/bgrt.plymouth.in.h:1 themes/spinner/spinner.plymouth.in.h:1
+msgid "Installing Updates..."
+msgstr "Updates worden uitgevoerd..."
+
+#: themes/bgrt/bgrt.plymouth.in.h:2 themes/spinner/spinner.plymouth.in.h:2
+msgid "Do not turn off your computer"
+msgstr "Schakel de computer niet uit"
+
+#: themes/bgrt/bgrt.plymouth.in.h:3 themes/spinner/spinner.plymouth.in.h:3
+msgid "Upgrading System..."
+msgstr "Besturingssysteem upgrade wordt uitgevoerd..."
index de15808102547868fafa0504cc5f917db6f75561..8f0abd9cea5077d3da9fcd87fc2106112ee05ca3 100644 (file)
@@ -19,6 +19,7 @@ libply_HEADERS = \
                    ply-list.h                                                \
                    ply-hashtable.h                                           \
                    ply-logger.h                                              \
+                   ply-i18n.h                                                \
                    ply-key-file.h                                            \
                    ply-progress.h                                            \
                    ply-rectangle.h                                           \
diff --git a/src/libply/ply-i18n.h b/src/libply/ply-i18n.h
new file mode 100644 (file)
index 0000000..94a4035
--- /dev/null
@@ -0,0 +1,28 @@
+/* ply-utils.h - i18n handling
+ *
+ * Copyright (C) 2019 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Written By: Hans de Goede <hdgoede@redhat.com>
+ */
+#ifndef PLY_I18N_H
+#define PLY_I18N_H
+
+#ifdef ENABLE_NLS
+#include <libintl.h>
+#define _(String) dgettext(PACKAGE, String)
+#else
+#define _(String) (String)
+#endif
+
+#endif /* PLY_I18N_H */
+/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
index 90e8a5eb4bfd325deb7f15e06c72f32f5b773da9..b06d29cb051a78b040a3f4f8e32a8f16831ae1d6 100644 (file)
@@ -36,6 +36,7 @@
 #include <paths.h>
 #include <assert.h>
 #include <values.h>
+#include <locale.h>
 
 #include <linux/kd.h>
 #include <linux/vt.h>
@@ -652,6 +653,8 @@ on_newroot (state_t    *state,
         chdir (root_dir);
         chroot (".");
         chdir ("/");
+        /* Update local now that we have /usr/share/locale available */
+        setlocale(LC_ALL, "");
         ply_progress_load_cache (state->progress, get_cache_file_for_mode (state->mode));
         if (state->boot_splash != NULL)
                 ply_boot_splash_root_mounted (state->boot_splash);
index 098f2629b2cee0793f5b8497f74f45a16f78246e..e8b91ec93da0ba1ab263058479a20d09096acb98 100644 (file)
@@ -53,6 +53,7 @@
 #include "ply-pixel-buffer.h"
 #include "ply-pixel-display.h"
 #include "ply-utils.h"
+#include "ply-i18n.h"
 
 #include "ply-animation.h"
 #include "ply-progress-animation.h"
@@ -509,7 +510,7 @@ view_load (view_t *view)
 
         if (plugin->mode_settings[plugin->mode].title) {
                 ply_label_set_text (view->title_label,
-                                    plugin->mode_settings[plugin->mode].title);
+                                    _(plugin->mode_settings[plugin->mode].title));
                 title_height = ply_label_get_height (view->title_label);
         } else {
                 ply_label_hide (view->title_label);
@@ -517,7 +518,7 @@ view_load (view_t *view)
 
         if (plugin->mode_settings[plugin->mode].subtitle) {
                 ply_label_set_text (view->subtitle_label,
-                                    plugin->mode_settings[plugin->mode].subtitle);
+                                    _(plugin->mode_settings[plugin->mode].subtitle));
                 subtitle_height = ply_label_get_height (view->subtitle_label);
         } else {
                 ply_label_hide (view->subtitle_label);
@@ -1805,7 +1806,7 @@ system_update (ply_boot_splash_plugin_t *plugin,
                 ply_progress_bar_set_percent_done (view->progress_bar, (double) progress / 100.f);
                 if (!ply_progress_bar_is_hidden (view->progress_bar) &&
                     plugin->mode_settings[plugin->mode].progress_bar_show_percent_complete) {
-                        snprintf (buf, sizeof(buf), "%d%% complete", progress);
+                        snprintf (buf, sizeof(buf), _("%d%% complete"), progress);
                         view_show_message (view, buf);
                 }
                 node = next_node;