Skip to content

Commit

Permalink
Use gettext for translations
Browse files Browse the repository at this point in the history
intltool is deprecated now that gettext support things like dekstop files.
  • Loading branch information
infirit committed May 16, 2020
1 parent 62126e5 commit 3a3b27e
Show file tree
Hide file tree
Showing 12 changed files with 171 additions and 64 deletions.
20 changes: 15 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,22 @@
/ltmain.sh
/m4

# intltoolize
/intltool-extract.in
/intltool-merge.in
/intltool-update.in
# gettext
/config.rpath
/ABOUT-NLS
/po/config.rpath
/po/Makefile.in.in
/po/Makefile.in
/po/Makefile
/po/Makevars.template
/po/quot.sed
/po/remove-potcdate.sin
/po/Rules-quot
/po/blueman.pot
/po/boldquot.sed
/po/*.header
/po/stamp-po
/po/insert-header.sin

# automake
Makefile.in
Expand Down Expand Up @@ -66,7 +77,6 @@ Makefile
/module/_blueman_la-*.lo
/module/_blueman_la-*.o
/po/*.gmo
/po/.intltool-merge-cache

# Local execution
/blueman/**/*.pyc
Expand Down
27 changes: 16 additions & 11 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,33 @@ DIST_DOCS = \

EXTRA_DIST = \
${DIST_DOCS} \
intltool-extract.in \
intltool-update.in \
intltool-merge.in \
meson.build \
po/meson.build

DISTCLEANFILES = \
intltool-extract \
intltool-update \
intltool-merge

MAINTAINERCLEANFILES = \
Makefile.in \
aclocal.m4 \
configure \
config.h.in \
config.rpath \
depcomp \
missing \
install-sh \
intltool-extract.in \
intltool-update.in \
intltool-merge.in
ABOUT-NLS \
config.rpath \
po/Makefile.in.in \
po/Makefile.in \
po/Makefile \
po/Makevars.template \
po/quot.sed \
po/remove-potcdate.sin \
po/Rules-quot \
po/blueman.pot \
po/boldquot.sed \
po/*.header \
po/stamp-po \
po/insert-header.sin \
$NULL

doc_DATA = ${DIST_DOCS}

Expand Down
7 changes: 1 addition & 6 deletions autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ if test -z "$AUTOGEN_SUBDIR_MODE" && test -z "$NOCONFIGURE"; then
fi


aclocal || exit $?
autoheader || exit $?
libtoolize --copy --automake || exit $?
intltoolize --automake --copy --force || exit $?
automake --add-missing --copy || exit $?
autoconf || exit $?
autoreconf --verbose --force --install || exit $?

if test -z "$AUTOGEN_SUBDIR_MODE" && test -z "$NOCONFIGURE"; then
$srcdir/configure --enable-maintainer-mode $AUTOGEN_CONFIGURE_ARGS "$@" || exit $?
Expand Down
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ dnl ==========================================================================
GETTEXT_PACKAGE="blueman"
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [The gettext package])
AM_GLIB_GNU_GETTEXT
IT_PROG_INTLTOOL([0.35.0])
AM_GNU_GETTEXT_VERSION([0.19.7])
AM_GNU_GETTEXT([external])

AC_ENABLE_SHARED(yes)
AC_ENABLE_STATIC(no)
Expand Down
19 changes: 13 additions & 6 deletions data/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
@INTLTOOL_DESKTOP_RULE@
autostartdir = $(sysconfdir)/xdg/autostart
autostart_in_files = blueman.desktop.in
autostart_DATA = $(autostart_in_files:.desktop.in=.desktop)

@INTLTOOL_DESKTOP_RULE@
$(autostart_DATA): $(autostart_in_files)
$(AM_V_GEN) $(MSGFMT) --desktop --template $< -d $(top_srcdir)/po -o $@

appdir = $(datadir)/applications
app_in_files = blueman-manager.desktop.in
app_DATA = $(app_in_files:.desktop.in=.desktop)

thunar_in_files = thunar-sendto-blueman.desktop.in
settings_in_files = blueman-adapters.desktop.in
$(app_DATA): $(app_in_files)
$(AM_V_GEN) $(MSGFMT) --desktop --template $< -d $(top_srcdir)/po -o $@

if HAVE_THUNAR
@INTLTOOL_DESKTOP_RULE@
thunardir = $(datadir)/Thunar/sendto
thunar_in_files = thunar-sendto-blueman.desktop.in
thunar_DATA = $(thunar_in_files:.desktop.in=.desktop)

$(thunar_DATA): $(thunar_in_files)
$(AM_V_GEN) $(MSGFMT) --desktop --template $< -d $(top_srcdir)/po -o $@
endif

if HAVE_SETTINGS
@INTLTOOL_DESKTOP_RULE@
settingsdir = $(datadir)/applications
settings_in_files = blueman-adapters.desktop.in
settings_DATA = $(settings_in_files:.desktop.in=.desktop)

$(settings_DATA): $(settings_in_files)
$(AM_V_GEN) $(MSGFMT) --desktop --template $< -d $(top_srcdir)/po -o $@
endif

gsettings_SCHEMAS = org.blueman.gschema.xml
Expand Down
11 changes: 7 additions & 4 deletions data/configs/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@ systemd_user_DATA = blueman-applet.service
endif

if HAVE_POLKIT
@INTLTOOL_POLICY_RULE@
policykitactionsdir = $(datadir)/polkit-1/actions
policykitactions_in_files = org.blueman.policy.in
policykitactions_DATA = $(policykitactions_in_files:.policy.in=.policy)
policykitactions_DATA = org.blueman.policy

org.blueman.policy: org.blueman.policy.in
$(AM_V_GEN) GETTEXTDATADIR=$(top_srcdir)/data/configs $(MSGFMT) --xml -d $(top_srcdir)/po/ -o $@ --template $<


policykitrulesdir = $(datadir)/polkit-1/rules.d
policykitrules_DATA = blueman.rules
endif

EXTRA_DIST = \
its \
blueman-applet.service.in \
blueman-mechanism.service.in \
org.blueman.Mechanism.conf \
Expand All @@ -40,8 +43,8 @@ CLEANFILES = \
blueman-applet.service \
blueman-mechanism.service \
org.blueman.Mechanism.service \
org.blueman.policy \
org.blueman.Applet.service \
org.blueman.policy \
$(BUILT_SOURCES)

DISTCLEANFILES = \
Expand Down
8 changes: 8 additions & 0 deletions data/configs/its/polkit.its
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<its:rules xmlns:its="http://www.w3.org/2005/11/its"
version="2.0">
<its:translateRule selector="//*" translate="no"/>
<its:translateRule selector="//action/description |
//action/message"
translate="yes"/>
</its:rules>
6 changes: 6 additions & 0 deletions data/configs/its/polkit.loc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0"?>
<locatingRules>
<locatingRule name="polkit policy" pattern="*.policy">
<documentRule localName="policyconfig" target="polkit.its"/>
</locatingRule>
</locatingRules>
21 changes: 9 additions & 12 deletions data/configs/org.blueman.policy.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,36 @@
<vendor>The Blueman Project</vendor>
<vendor_url>https://github.com/blueman-project/blueman</vendor_url>
<icon_name>blueman</icon_name>

<action id="org.blueman.network.setup">
<_description>Configure Bluetooth Network</_description>
<_message>Configuring networking requires privileges</_message>

<description>Configure Bluetooth Network</description>
<message>Configuring networking requires privileges</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>auth_admin_keep</allow_active>

</defaults>
</action>

<action id="org.blueman.dhcp.client">
<_description>Launch DHCP client</_description>
<_message>Launching DHCP client requires privileges</_message>
<description>Launch DHCP client</description>
<message>Launching DHCP client requires privileges</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>auth_admin_keep</allow_active>
</defaults>
</action>

<action id="org.blueman.pppd.pppconnect">
<_description>Launch PPP daemon</_description>
<_message>Launching PPP daemon requires privileges</_message>
<description>Launch PPP daemon</description>
<message>Launching PPP daemon requires privileges</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>auth_admin_keep</allow_active>
</defaults>
</action>

<action id="org.blueman.rfkill.setstate">
<_description>Set RfKill State</_description>
<_message>Setting RfKill State requires privileges</_message>
<description>Set RfKill State</description>
<message>Setting RfKill State requires privileges</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>auth_admin_keep</allow_active>
Expand Down
10 changes: 4 additions & 6 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,14 @@ install_subdir(
install_data('data/org.blueman.gschema.xml', install_dir: schemadir)
install_data('data/pin-code-database.xml', install_dir: pkgdatadir)

# FIXME when polkit 0.114 is in stable releases use i18n.merge_file, until then use intltool
# Merge translation into policy file
intltool_merge = find_program('intltool-merge')
podir = join_paths('@CURRENT_SOURCE_DIR@', 'po')

custom_target('org.blueman.policy',
i18n.merge_file(
input: 'data/configs/org.blueman.policy.in',
output: 'org.blueman.policy',
type: 'xml',
po_dir: 'po',
data_dirs: 'data/configs',
install: true,
command: [intltool_merge, '--xml-style', podir, '@INPUT@', '@OUTPUT@'],
install_dir: join_paths(datadir, 'polkit-1', 'actions'),
)

Expand Down
78 changes: 78 additions & 0 deletions po/Makevars
Original file line number Diff line number Diff line change
@@ -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 = --from-code=UTF-8 --keyword=_ --keyword=N_ --keyword=C_:1c,2 --keyword=NC_:1c,2 --keyword=g_dngettext:2,3 --add-comments

# 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 = Copyright © 2008 - 2020 blueman project

# 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 =

# 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
24 changes: 12 additions & 12 deletions po/POTFILES.in
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[type: gettext/glade]data/ui/adapters-tab.ui
[type: gettext/glade]data/ui/applet-passkey.ui
[type: gettext/glade]data/ui/manager-main.ui
[type: gettext/glade]data/ui/rename-device.ui
[type: gettext/glade]data/ui/services-network.ui
[type: gettext/glade]data/ui/services-transfer.ui
[type: gettext/glade]data/ui/send-dialog.ui
[type: gettext/glade]data/ui/assistant.ui
[type: gettext/glade]data/ui/applet-plugins-widget.ui
[type: gettext/glade]data/ui/gsm-settings.ui
[type: gettext/glade]data/ui/net-usage.ui
[type: gettext/glade]data/ui/note.ui
data/ui/adapters-tab.ui
data/ui/applet-passkey.ui
data/ui/manager-main.ui
data/ui/rename-device.ui
data/ui/services-network.ui
data/ui/services-transfer.ui
data/ui/send-dialog.ui
data/ui/assistant.ui
data/ui/applet-plugins-widget.ui
data/ui/gsm-settings.ui
data/ui/net-usage.ui
data/ui/note.ui
blueman/main/Adapter.py
blueman/main/DBusProxies.py
blueman/main/Manager.py
Expand Down

0 comments on commit 3a3b27e

Please sign in to comment.