Fwd: Re: kdereview/plasma/dataengines/nowplaying
Albert Astals Cid
aacid at kde.org
Tue Apr 1 22:54:49 CEST 2008
A Dimarts 01 Abril 2008, Alex Merry va escriure:
> On Tuesday 01 April 2008 20:06:39 Albert Astals Cid wrote:
> > A Dimarts 01 Abril 2008, Alex Merry va escriure:
> > > I think we should sort out how translations work in dataengines
> > > conclusively...
> >
> > I don't have a clue what a dataengine is and how it works, so please give
> > some additional info when discussing about how translations should work
> > on dataengines.
>
> Data engines act as an easy way to access information. Applets can request
> a source from a data engine (the source name is a QString). The engine
> then sends a signal to the applet when there is data added to the source,
> or when the data changes. This data is a map from QString to QVariant.
>
> For example, the time engine has a source for each timezone, including the
> source "Local" for the system timezone. A clock applet requests a source
> such as "Local" or "Europe/Paris", and the engine populates that source
> with a map with data["Date"] being a QDate (encapsulated in a QVariant) and
> data["Time"] being a QTime.
>
> A clock would typically use the result of data["Time"] and data["Date"].
> So these keys need to be predictable (you can't translate them in the
> engine).
>
> However, you could write an applet that simply printed every key and the
> corresponding value, like
> Time: 14.52
> Date: 31st March 2008
>
> In order for "Date" and "Time" to be translated without the applet knowing
> beforehand what the key is (since it may be a generic applet that allows
> the user to pick a data engine), I18N_NOOP needs to be called on the data
> in the engine, then the applet needs to call i18n() on the strings. This
> will work because the data engine and the applet are both contained in the
> plasma application, and so have access to the same strings.
>
> The validity of this use case is more obvious with the now playing engine,
> where the available keys may depend on the player, and simply dumping the
> results is useful.
>
> However, the now playing engine contains keys like "State"
> (playing/paused/stopped) and "Artist" which may well be context-dependent
> in some languages (such as a different word for a painter and a musician).
> Using I18N_NOOP2 with a context argument would allow accurate translations,
> but would mean the applet writer would have to know in advance what the
> context was. This can't be used with a generic "display all the data from
> any engine" applet (or the plasmaengineexplorer program).
So what about a
QString translatedKey(const QString &key) const;
function in the dataengine?
That does something like
if (key == "Artist") return i18nc("The performer of a song", "Artist");
else if (key == "Track") return i18nc("The track of song", Track");
...
In my opinion fixes the issue of calling i18n over a string that you did not
generate yourself and places the responsability where it's due.
Albert
>
> Alex
>
> > Also please CC me as i'm not on panel-devel.
> >
> > Albert
> >
> > > Alex
> > >
> > >
> > > ---------- Forwarded Message ----------
> > >
> > > Subject: Re: kdereview/plasma/dataengines/nowplaying
> > > Date: Tuesday 01 April 2008
> > > From: Albert Astals Cid <aacid at kde.org>
> > > To: kde-i18n-doc at kde.org
> > >
> > > A Dimarts 01 Abril 2008, Alex Merry va escriure:
> > > > SVN commit 792560 by alexmerry:
> > > >
> > > > Add some i18n support.
> > > >
> > > > I'm slightly concerned that the translations may not be easy without
> > > > context, but including context means that applets can't just call
> > > > i18n() on all strings (which is kind of the point of the I18N_NOOP
> > > > calls). CC'ing the kde-i18n-doc list for comments.
> > > >
> > > > This should finally address all the issues raised by the review
> > > > process.
> > >
> > > In my opinion this is a very weird and wrong behaviour, if the clients
> > > do not have to use the text, don't mark it with I18N_NOOP, if they have
> > > to use it, give it already i18n'ed and add context to help translation.
> > >
> > > Albert
> > >
> > > > CCMAIL: kde-i18n-doc at kde.org
> > > >
> > > >
> > > >
> > > > M +6 -0 CMakeLists.txt
> > > > AM Messages.sh
> > > > M +35 -36 nowplayingengine.cpp
> > > >
> > > >
> > > > --- trunk/kdereview/plasma/dataengines/nowplaying/CMakeLists.txt
> > > > #792559:792560 @@ -20,6 +20,9 @@
> > > > QT4_ADD_DBUS_INTERFACE(nowplaying_engine_SRCS ${juk_xml}
> > > > juk_interface) set(nowplaying_engine_SRCS ${nowplaying_engine_SRCS}
> > > > juk.cpp) set(JUK_FOUND ON)
> > > > + message(STATUS "Found JuK D-Bus interface specification: the
> > > > nowplaying dataengine will support JuK") +else(EXISTS ${juk_xml})
> > > > + message(STATUS "JuK D-Bus interface specification NOT found: the
> > > > nowplaying dataengine will NOT support JuK") endif(EXISTS ${juk_xml})
> > > > macro_log_feature(JUK_FOUND "JuK" "Jukebox and music manager for
> > > > KDE" "http://developer.kde.org/~wheeler/juk.html" FALSE "" "Support
> > > > for JuK in the Now Playing data engine")
> > > >
> > > > @@ -31,6 +34,9 @@
> > > > include_directories(${XMMS_INCLUDE_DIRS})
> > > > include_directories(${GLIB2_INCLUDE_DIR})
> > > > set(nowplaying_engine_SRCS ${nowplaying_engine_SRCS} xmms.cpp)
> > > > + message(STATUS "Found XMMS: the nowplaying dataengine will
> > > > support XMMS 1.x") + else(XMMS_FOUND)
> > > > + message(STATUS "Could NOT find XMMS: the nowplaying dataengine
> > > > will NOT support XMMS 1.x") endif(XMMS_FOUND)
> > > > endif(GLIB2_FOUND)
> > > >
> > > > ** trunk/kdereview/plasma/dataengines/nowplaying/Messages.sh
> > > > #property svn:executable + *
> > > > ---
> > > > trunk/kdereview/plasma/dataengines/nowplaying/nowplayingengine.cpp
> > > > #792559:792560 @@ -68,8 +68,8 @@
> > > > kDebug() << "Source" << source << "was requested";
> > > > QString lowerSource = source.toLower();
> > > > if (lowerSource == "help") {
> > > > - setData(source, "Use 'players' to get a list of players.\n"
> > > > - "Use 'properties' to get a list of all
> > > > properties that may be returned." + setData(source,
> > > > I18N_NOOP("Use 'players' to get a list of players.\n" +
> > > > "Use 'properties' to get a list of all properties that may be
> > > > returned.") /* "\n"
> > > > "Players can be controlled with\n"
> > > > @@ -89,26 +89,26 @@
> > > > );
> > > > return true;
> > > > } else if (lowerSource == "properties") {
> > > > - setData(source, "State", "QString -
> > > > playing|paused|stopped"); - setData(source, "Artist",
> > > > "QString - the artist metadata for the\n" -
> > > > " current track, if available"); -
> > > > setData(source, "Album", "QString - the album metadata for
> > > > the\n" - " current
> > > > track, if available"); - setData(source, "Title",
> > > > "QString - the title metadata for the\n" -
> > > > " current track, if available"); - setData(source,
> > > > "Track number", "int - the album/collection track number\n" -
> > > > " (eg: on a CD) if known, 0
> > > > otherwise"); - setData(source, "Comment", "QString -
> > > > the comment metadata for the\n" -
> > > > " current track, if available"); - setData(source, "Genre",
> > > > "QString - the comment metadata for the\n" -
> > > > " current track, if available"); -
> > > > setData(source, "Length", "int - the length of the
> > > > current track\n" - "
> > > > in seconds, 0 if unknown"); - setData(source, "Position",
> > > > "int - the position of the current track\n" -
> > > > " in seconds, 0 if unknown"); - setData(source,
> > > > "Volume", "float - the volume, given as a float\n" -
> > > > " between 0 and 1, or -1 if unknown"); -
> > > > setData(source, "Artwork", "QPixmap - the album artwork, if
> > > > available"); + setData(source, "State",
> > > > I18N_NOOP("QString - playing|paused|stopped")); +
> > > > setData(source, "Artist",
> > > > I18N_NOOP("QString - the artist metadata for the\n" +
> > > > " current track, if
> > > > available")); + setData(source, "Album", I18N_NOOP("QString
> > > > - the album metadata for the\n" +
> > > > " current track, if available")); + setData(source, "Title",
> > > > I18N_NOOP("QString - the title metadata for the\n" +
> > > > " current track, if
> > > > available")); + setData(source, "Track number",
> > > > I18N_NOOP("int - the album/collection track number\n" +
> > > > " (eg: on a CD) if known, 0 otherwise"));
> > > > + setData(source, "Comment", I18N_NOOP("QString - the comment
> > > > metadata for the\n" +
> > > > " current track, if available")); + setData(source, "Genre",
> > > > I18N_NOOP("QString - the comment metadata for the\n" +
> > > > " current track, if
> > > > available")); + setData(source, "Length",
> > > > I18N_NOOP("int - the length of the current track\n" +
> > > > " in seconds, 0 if unknown")); +
> > > > setData(source, "Position", I18N_NOOP("int - the position
> > > > of the current track\n" +
> > > > " in seconds, 0 if unknown")); + setData(source, "Volume",
> > > > I18N_NOOP("float - the volume, given as a float\n" +
> > > > " between 0 and 1, or -1
> > > > if unknown")); + setData(source, "Artwork",
> > > > I18N_NOOP("QPixmap - the album artwork, if available")); #if 0
> > > > setData(source, "Can play", "bool - whether the
> > > > 'play' command can be\n" " expected to have any effect\n" @@
> > > > -143,7 +143,6 @@
> > > > } else if (lowerSource == "players") {
> > > > setData(source, sources());
> > > > return true;
> > > > - } else if (lowerSource == "players") {
> > > > //FIXME: this belongs in a dataSink, or whatever we're calling
> > > > it #if 0
> > > > } else if (source.contains(':')) {
> > > > @@ -238,26 +237,26 @@
> > > >
> > > > switch(player->state()) {
> > > > case Player::Playing:
> > > > - setData(source, "State", "playing");
> > > > + setData(source, I18N_NOOP("State"),
> > > > I18N_NOOP("playing")); break;
> > > > case Player::Paused:
> > > > - setData(source, "State", "paused");
> > > > + setData(source, I18N_NOOP("State"),
> > > > I18N_NOOP("paused")); break;
> > > > case Player::Stopped:
> > > > - setData(source, "State", "stopped");
> > > > + setData(source, I18N_NOOP("State"),
> > > > I18N_NOOP("stopped")); break;
> > > > }
> > > >
> > > > - setData(source, "Artist", player->artist());
> > > > - setData(source, "Album", player->album());
> > > > - setData(source, "Title", player->title());
> > > > - setData(source, "Track number", player->trackNumber());
> > > > - setData(source, "Comment", player->comment());
> > > > - setData(source, "Genre", player->genre());
> > > > - setData(source, "Length", player->length());
> > > > - setData(source, "Position", player->position());
> > > > - setData(source, "Volume", player->volume());
> > > > - setData(source, "Artwork", player->artwork());
> > > > + setData(source, I18N_NOOP("Artist"), player->artist());
> > > > + setData(source, I18N_NOOP("Album"), player->album());
> > > > + setData(source, I18N_NOOP("Title"), player->title());
> > > > + setData(source, I18N_NOOP("Track number"),
> > > > player->trackNumber()); + setData(source, I18N_NOOP("Comment"),
> > > > player->comment()); + setData(source, I18N_NOOP("Genre"),
> > > > player->genre());
> > > > + setData(source, I18N_NOOP("Length"), player->length());
> > > > + setData(source, I18N_NOOP("Position"), player->position());
> > > > + setData(source, I18N_NOOP("Volume"), player->volume());
> > > > + setData(source, I18N_NOOP("Artwork"), player->artwork());
> > > > // FIXME: re-enable when we have a dataSink
> > > > #if 0
> > > > setData(source, "Can play", player->canPlay());
> > >
> > > -------------------------------------------------------
> >
> > _______________________________________________
> > Panel-devel mailing list
> > Panel-devel at kde.org
> > https://mail.kde.org/mailman/listinfo/panel-devel
More information about the Panel-devel
mailing list