]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Don't extract Icon values from .desktop files into POT files.
authorBruno Haible <bruno@clisp.org>
Sun, 18 Aug 2019 11:27:30 +0000 (13:27 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 13 Apr 2020 11:04:58 +0000 (13:04 +0200)
Reported by Piotr Drąg <piotrdrag@gmail.com>
at <https://savannah.gnu.org/support/?108887>
and by Will Thompson <wjt@endlessm.com>
at <https://savannah.gnu.org/bugs/?56543>.

There was a discussion starting at
<https://lists.freedesktop.org/archives/xdg/2019-June/014158.html>.
The most interesting posts in this thread were
<https://lists.freedesktop.org/archives/xdg/2019-June/014164.html>
<https://lists.freedesktop.org/archives/xdg/2019-June/014167.html>.

* gettext-tools/doc/gettext.texi (Icons): New subsubsection.
* gettext-tools/src/read-desktop.c (desktop_add_default_keywords): Don't add
"Icon".
* gettext-tools/src/x-desktop.c: Update comments.
* gettext-tools/doc/xgettext.texi (Desktop): Remove 'Icon' from the list of
extracted keys.
* gettext-tools/tests/xgettext-desktop-2: New file.
* gettext-tools/tests/msgfmt-desktop-3: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add them.
* NEWS: Mention the change.

NEWS
gettext-tools/doc/gettext.texi
gettext-tools/doc/xgettext.texi
gettext-tools/src/read-desktop.c
gettext-tools/src/x-desktop.c
gettext-tools/tests/Makefile.am
gettext-tools/tests/msgfmt-desktop-3 [new file with mode: 0755]
gettext-tools/tests/xgettext-desktop-2 [new file with mode: 0755]

diff --git a/NEWS b/NEWS
index f8ad81ed098216a0af8d828f98e8a7596533fa5c..8913a61a365bede3db9592233ef678e715c49d50 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,10 @@
 Version 0.20.2 - April 2020
 
+* Programming languages support:
+  - Desktop Entry:
+    The value of the 'Icon' property is no longer extracted into the POT file
+    by xgettext.  The documentation explains how to localize icons.
+
 * Runtime behaviour:
   - Fixed a multithread-safety bug on Cygwin and native Windows.
 
index 310c9f70ec19151529dc55f2035c5e19f58a66cd..87c903af2e102459923eef780d7b23aeb57eef36 100644 (file)
@@ -12730,6 +12730,60 @@ desktop entry file.
 
 For more information, see the example @code{hello-c-gnome3}.
 
+@menu
+* Icons::                       Handling icons
+@end menu
+
+@node Icons
+@subsubsection How to handle icons in Desktop Entry files
+
+Icons are generally locale dependent, for the following reasons:
+
+@itemize @bullet
+@item
+Icons may contain signs that are considered rude in some cultures.  For
+example, the high-five sign, in some cultures, is perceived as an
+unfriendly ``stop'' sign.
+@item
+Icons may contain metaphors that are culture specific.  For example, a
+mailbox in the U.S. looks different than mailboxes all around the world.
+@item
+Icons may need to be mirrored for right-to-left locales.
+@item
+Icons may contain text strings (a bad practice, but anyway).
+@end itemize
+
+However, icons are not covered by GNU gettext localization, because
+@itemize @bullet
+@item
+Icons cannot be easily embedded in PO files,
+@item
+The need to localize an icon is rare, and the ability to do so in a PO
+file would introduce translator mistakes.
+@c https://lists.freedesktop.org/archives/xdg/2019-June/014168.html
+@end itemize
+
+Desktop Entry files may contain an @samp{Icon} property, and this
+property is localizable.  If a translator wishes to localize an icon,
+she should do so by bypassing the normal workflow with PO files:
+@enumerate
+@item
+The translator contacts the package developers directly, sending them
+the icon appropriate for her locale, with a request to change the
+template file.
+@item
+The package developers add the icon file to their repository, and a
+line
+@smallexample
+Icon[@var{locale}]=@var{icon_file_name}
+@end smallexample
+@noindent
+to the template file.
+@end enumerate
+@noindent
+This line remains in place when this template file is merged with the
+translators' PO files, through @code{msgfmt}.
+
 @node XML
 @subsection XML files
 
index 7a8b516a837693ec2005c70b28d7a02512d21211..f12af6acab90f1b7d3efdb1def172410422df1ea 100644 (file)
@@ -345,7 +345,7 @@ For Vala: @code{_}, @code{Q_}, @code{N_}, @code{NC_}, @code{dgettext:2},
 
 @item
 For Desktop: @code{Name}, @code{GenericName}, @code{Comment},
-@code{Icon}, @code{Keywords}.
+@code{Keywords}.
 @end itemize
 
 To disable the default keyword specifications, the option @samp{-k} or
index 41bde41e1d593e8b72553d4b577b68eb91b1b20e..4de134f3cc6dfc77b3e8b46163e9b2748ca87856 100644 (file)
@@ -1,5 +1,5 @@
 /* Reading Desktop Entry files.
-   Copyright (C) 1995-1998, 2000-2003, 2005-2006, 2008-2009, 2014-2018 Free
+   Copyright (C) 1995-1998, 2000-2003, 2005-2006, 2008-2009, 2014-2019 Free
    Software Foundation, Inc.
    This file was written by Daiki Ueno <ueno@gnu.org>.
 
@@ -640,6 +640,8 @@ desktop_add_default_keywords (hash_table *keywords)
   desktop_add_keyword (keywords, "Name", false);
   desktop_add_keyword (keywords, "GenericName", false);
   desktop_add_keyword (keywords, "Comment", false);
+#if 0 /* Icon values are localizable, but not supported by xgettext.  */
   desktop_add_keyword (keywords, "Icon", false);
+#endif
   desktop_add_keyword (keywords, "Keywords", true);
 }
index fc3d7e1fa788815c6d19d31f5294d7da42085339..93e206ee9c188fd01c1a3f563f628fd56de19ed9 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext Desktop Entry backend.
-   Copyright (C) 2014, 2018 Free Software Foundation, Inc.
+   Copyright (C) 2014, 2018-2019 Free Software Foundation, Inc.
 
    This file was written by Daiki Ueno <ueno@gnu.org>, 2014.
 
 /* The syntax of a Desktop Entry file is defined at
    https://standards.freedesktop.org/desktop-entry-spec/latest/index.html
 
-   Basically, values with 'localestring' type can be translated.
+   Basically, values with 'localestring' type can be localized.
+   However, the values of 'Icon', while being localizable, are not supported
+   by xgettext.  See the documentation for more info.
 
    The type of a value is determined by looking at the key associated
    with it.  The list of available keys are listed on:
-   https://standards.freedesktop.org/desktop-entry-spec/latest/ar01s05.html  */
+   https://standards.freedesktop.org/desktop-entry-spec/latest/ar01s04.html  */
 
 static hash_table keywords;
 static bool default_keywords = true;
index 6aa3d563625b77ffe8d888be2688c4871a74fe7f..b200aa342d4f32fc34a3251bda33b6eec8e5985e 100644 (file)
@@ -52,7 +52,7 @@ TESTS = gettext-1 gettext-2 \
        msgfmt-15 msgfmt-16 msgfmt-17 msgfmt-18 msgfmt-19 \
        msgfmt-properties-1 \
        msgfmt-qt-1 msgfmt-qt-2 \
-       msgfmt-desktop-1 msgfmt-desktop-2 \
+       msgfmt-desktop-1 msgfmt-desktop-2 msgfmt-desktop-3 \
        msgfmt-xml-1 msgfmt-xml-2 \
        msggrep-1 msggrep-2 msggrep-3 msggrep-4 msggrep-5 msggrep-6 msggrep-7 \
        msggrep-8 msggrep-9 msggrep-10 msggrep-11 \
@@ -122,7 +122,7 @@ TESTS = gettext-1 gettext-2 \
        xgettext-javascript-7 \
        xgettext-vala-1 xgettext-vala-2 \
        xgettext-gsettings-1 \
-       xgettext-desktop-1 \
+       xgettext-desktop-1 xgettext-desktop-2 \
        xgettext-its-1 xgettext-its-2 \
        format-awk-1 format-awk-2 \
        format-boost-1 format-boost-2 \
diff --git a/gettext-tools/tests/msgfmt-desktop-3 b/gettext-tools/tests/msgfmt-desktop-3
new file mode 100755 (executable)
index 0000000..149d9c2
--- /dev/null
@@ -0,0 +1,70 @@
+#! /bin/sh
+. "${srcdir=.}/init.sh"; path_prepend_ . ../src
+
+# Test of Icon handling in Desktop Entry support.
+
+cat <<\EOF > hello.desktop
+[Desktop Entry]
+Name=Hello
+TryExec=hello
+Exec=hello
+Icon=handshake.jpg
+Icon[en_US]=hifive.jpg
+Icon[th]=wai.jpg
+Type=Application
+Keywords=Utility;
+EOF
+
+cat <<\EOF > th.po
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2019-08-18 12:45+0200\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: Thai <th@li.org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: hello.desktop:3
+msgid "Hello"
+msgstr "สวัสดี"
+
+#: hello.desktop:10
+msgid "Utility;"
+msgstr "ประโยชน์;"
+EOF
+
+cat <<\EOF > hello.desktop.ok
+[Desktop Entry]
+Name[th]=สวัสดี
+Name=Hello
+TryExec=hello
+Exec=hello
+Icon=handshake.jpg
+Icon[en_US]=hifive.jpg
+Icon[th]=wai.jpg
+Type=Application
+Keywords[th]=ประโยชน์;
+Keywords=Utility;
+EOF
+
+# Generate the merged .desktop file.
+
+${MSGFMT} --desktop --template=hello.desktop -l th th.po -o hello.desktop.tmp \
+  || Exit 1
+LC_ALL=C tr -d '\r' < hello.desktop.tmp > hello.desktop.out || Exit 1
+
+: ${DIFF=diff}
+${DIFF} hello.desktop.ok hello.desktop.out
+result=$?
+
+exit $result
diff --git a/gettext-tools/tests/xgettext-desktop-2 b/gettext-tools/tests/xgettext-desktop-2
new file mode 100755 (executable)
index 0000000..a01f7cf
--- /dev/null
@@ -0,0 +1,55 @@
+#!/bin/sh
+. "${srcdir=.}/init.sh"; path_prepend_ . ../src
+
+# Test of Icon handling in Desktop Entry support.
+
+: ${XGETTEXT=xgettext}
+
+cat <<\EOF > hello.desktop
+[Desktop Entry]
+Name=Hello
+TryExec=hello
+Exec=hello
+Icon=handshake.jpg
+Icon[en_US]=hifive.jpg
+Icon[th]=wai.jpg
+Type=Application
+Keywords=Utility;
+EOF
+
+${XGETTEXT} --add-comments -o xg-de-2.tmp hello.desktop || Exit 1
+grep -v 'POT-Creation-Date' < xg-de-2.tmp > hello-desktop.pot || Exit 1
+
+cat <<\EOF > hello-desktop.ok
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: hello.desktop:3
+msgid "Hello"
+msgstr ""
+
+#: hello.desktop:10
+msgid "Utility;"
+msgstr ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} hello-desktop.ok hello-desktop.pot
+result=$?
+
+exit $result