From: Hans de Goede Date: Tue, 26 Feb 2019 10:03:36 +0000 (+0100) Subject: Add support for translating the user visible strings in some themes X-Git-Tag: 0.9.5~70^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b0ea667525dcbe9bce9d57aa1ae9b59c9a75441f;p=thirdparty%2Fplymouth.git Add support for translating the user visible strings in some themes 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 --- diff --git a/Makefile.am b/Makefile.am index cb6eedbd..2d38de13 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 diff --git a/configure.ac b/configure.ac index 78550d08..97710274 100644 --- a/configure.ac +++ b/configure.ac @@ -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 index 00000000..bec81d2b --- /dev/null +++ b/po/LINGUAS @@ -0,0 +1 @@ +nl diff --git a/po/Makevars b/po/Makevars new file mode 100644 index 00000000..40e01c85 --- /dev/null +++ b/po/Makevars @@ -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 index 00000000..bbce0ef7 --- /dev/null +++ b/po/POTFILES.in @@ -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 index 00000000..8c7cbc9b --- /dev/null +++ b/po/Rules-themes @@ -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 index 00000000..f730bce3 --- /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 , 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 \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..." diff --git a/src/libply/Makefile.am b/src/libply/Makefile.am index de158081..8f0abd9c 100644 --- a/src/libply/Makefile.am +++ b/src/libply/Makefile.am @@ -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 index 00000000..94a4035e --- /dev/null +++ b/src/libply/ply-i18n.h @@ -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 + */ +#ifndef PLY_I18N_H +#define PLY_I18N_H + +#ifdef ENABLE_NLS +#include +#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: */ diff --git a/src/main.c b/src/main.c index 90e8a5eb..b06d29cb 100644 --- a/src/main.c +++ b/src/main.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -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); diff --git a/src/plugins/splash/two-step/plugin.c b/src/plugins/splash/two-step/plugin.c index 098f2629..e8b91ec9 100644 --- a/src/plugins/splash/two-step/plugin.c +++ b/src/plugins/splash/two-step/plugin.c @@ -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;