Merge lp:~thomas-e-zander/exaile/artist_strip into lp:exaile/0.3.3

Proposed by Thomas Zander
Status: Superseded
Proposed branch: lp:~thomas-e-zander/exaile/artist_strip
Merge into: lp:exaile/0.3.3
Diff against target: 210 lines
6 files modified
data/ui/collection_prefs_pane.glade (+70/-0)
po/de.po (+4/-0)
xl/common.py (+4/-1)
xlgui/prefs/__init__.py (+2/-2)
xlgui/prefs/collection_prefs.py (+66/-0)
xlgui/prefs/widgets.py (+1/-0)
To merge this branch: bzr merge lp:~thomas-e-zander/exaile/artist_strip
Reviewer Review Type Date Requested Status
Johannes Sasongko Needs Fixing
Review via email: mp+12207@code.launchpad.net

This proposal has been superseded by a proposal from 2009-10-04.

To post a comment you must log in.
Revision history for this message
Johannes Sasongko (sjohannes) wrote :

Rather than

+ default_list = ["el", "l'", "la", "le", "les", "los", "the"]
+ try:
+ (loc, enc) = getlocale()
+ if loc is None:
+ (loc, enc) = getdefaultlocale()
+ #TRANSLATORS: Alter default_list to appropriate content
+ if loc == 'de_DE':
+ default_list.extend(["der", "die", "das"])

I'd prefer it to be a translatable string that translators can override completely. Something like

  #TRANSLATORS: ...
  default_list = _("the ")

A translator can then translate that, e.g.

  "the" --> "le ;l';les "

This way, on locales where this kind of stripping doesn't make sense at all, it can be translated as

  "the" --> ""

review: Needs Fixing
Revision history for this message
Johannes Sasongko (sjohannes) wrote :

Sorry, the last two snippets should be:

  "the " --> "le ;l';les "

and

  "the " --> ""

Revision history for this message
Thomas Zander (thomas-e-zander) wrote :

On Tue, Sep 22, 2009 at 18:59, Johannes Sasongko <email address hidden> wrote:
> Sorry, the last two snippets should be:
>
>  "the " --> "le ;l';les "
>
> and
>
>  "the " --> ""

While an empty list is no problem in any implementation, your
suggestion of using a translatable string saves the
if-else-locale-compare tree. Nice!
I'll look into that. Thanks for the useful review.

2425. By Thomas Zander

Sync with exaile main dev branch

2426. By Thomas Zander

Sync with exaile main dev branch

2427. By Thomas Zander

Sync with exaile main dev branch

2428. By Thomas Zander

Address review comments by Johannes Sasongko on 20090922

2429. By Thomas Zander

Sync with exaile main dev branch

2430. By Thomas Zander

Transfer the copyright of xlgui/prefs/collection_prefs.py to Adam Olsen and license it following GPLv2 and later

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'data/ui/collection_prefs_pane.glade'
--- data/ui/collection_prefs_pane.glade 1970-01-01 00:00:00 +0000
+++ data/ui/collection_prefs_pane.glade 2009-10-04 12:40:23 +0000
@@ -0,0 +1,70 @@
1<?xml version="1.0"?>
2<interface>
3 <requires lib="gtk+" version="2.16"/>
4 <!-- interface-naming-policy project-wide -->
5 <object class="GtkWindow" id="prefs_window">
6 <child>
7 <object class="GtkVBox" id="prefs_pane">
8 <property name="visible">True</property>
9 <property name="border_width">3</property>
10 <child>
11 <object class="GtkHBox" id="box1">
12 <property name="visible">True</property>
13 <property name="border_width">0</property>
14 <child>
15 <object class="GtkLabel" id="strip_list_label">
16 <property name="label" translatable="yes">Strip these words from the beginnng of the artist tag (space separated):</property>
17 <property name="receives_default">False</property>
18 <property name="wrap">True</property>
19 </object>
20 <packing>
21 <property name="expand">False</property>
22 <property name="fill">False</property>
23 <property name="position">0</property>
24 </packing>
25 </child>
26 </object>
27 <packing>
28 <property name="expand">False</property>
29 <property name="fill">False</property>
30 <property name="position">0</property>
31 </packing>
32 </child>
33 <child>
34 <object class="GtkEntry" id="collection/strip_list">
35 <property name="receives_default">False</property>
36 </object>
37 <packing>
38 <property name="expand">False</property>
39 <property name="fill">False</property>
40 <property name="position">1</property>
41 </packing>
42 </child>
43 <child>
44 <object class="GtkLabel" id="collection/strip_list_label2">
45 <property name="label" translatable="yes">(Right click for reset to defaults)</property>
46 <property name="receives_default">False</property>
47 </object>
48 <packing>
49 <property name="expand">False</property>
50 <property name="fill">False</property>
51 <property name="position">2</property>
52 </packing>
53 </child>
54 <child>
55 <object class="GtkCheckButton" id="collection/file_based_compilations">
56 <property name="label" translatable="yes">Use file based compilation detection</property>
57 <property name="visible">True</property>
58 <property name="can_focus">True</property>
59 <property name="receives_default">False</property>
60 </object>
61 <packing>
62 <property name="expand">False</property>
63 <property name="fill">False</property>
64 <property name="position">3</property>
65 </packing>
66 </child>
67 </object>
68 </child>
69 </object>
70</interface>
071
=== modified file 'po/de.po'
--- po/de.po 2009-09-24 16:42:31 +0000
+++ po/de.po 2009-10-04 12:40:23 +0000
@@ -1160,6 +1160,10 @@
1160msgid "Shortcut"1160msgid "Shortcut"
1161msgstr "Tastenkürzel"1161msgstr "Tastenkürzel"
11621162
1163#: ../xlgui/prefs/collection_prefs.py:27
1164msgid "el l' la le les los the"
1165msgstr "el l' la le les los the der die das"
1166
1163#: ../xlgui/tray.py:751167#: ../xlgui/tray.py:75
1164msgid "Exaile Music Player"1168msgid "Exaile Music Player"
1165msgstr "Exaile Musikwiedergabe"1169msgstr "Exaile Musikwiedergabe"
11661170
=== modified file 'xl/common.py'
--- xl/common.py 2009-09-08 18:29:32 +0000
+++ xl/common.py 2009-10-04 12:40:23 +0000
@@ -310,7 +310,10 @@
310 sorting310 sorting
311 """311 """
312 lowered = field.lower()312 lowered = field.lower()
313 for word in ("el ", "l'", "la ", "le ", "les ", "los ", "the "):313 import settings
314 for word in settings.get_option('collection/strip_list', ''):
315 if not word.endswith("'"):
316 word += ' '
314 if lowered.startswith(word):317 if lowered.startswith(word):
315 field = field[len(word):]318 field = field[len(word):]
316 break319 break
317320
=== modified file 'xlgui/prefs/__init__.py'
--- xlgui/prefs/__init__.py 2009-09-08 16:03:10 +0000
+++ xlgui/prefs/__init__.py 2009-10-04 12:40:23 +0000
@@ -33,7 +33,7 @@
33from xl import xdg33from xl import xdg
34from xl.settings import _SETTINGSMANAGER34from xl.settings import _SETTINGSMANAGER
35from xlgui.prefs.widgets import *35from xlgui.prefs.widgets import *
36from xlgui.prefs import playlists_prefs, osd_prefs36from xlgui.prefs import playlists_prefs, osd_prefs, collection_prefs
37from xlgui.prefs import cover_prefs, playback_prefs, appearance_prefs37from xlgui.prefs import cover_prefs, playback_prefs, appearance_prefs
38from xlgui.prefs import plugin_prefs38from xlgui.prefs import plugin_prefs
39import logging, traceback, gobject39import logging, traceback, gobject
@@ -46,7 +46,7 @@
46 """46 """
4747
48 PAGES = (playlists_prefs, appearance_prefs, playback_prefs, 48 PAGES = (playlists_prefs, appearance_prefs, playback_prefs,
49 osd_prefs, cover_prefs)49 collection_prefs, osd_prefs, cover_prefs)
50 PREFERENCES_DIALOG = None50 PREFERENCES_DIALOG = None
5151
52 def __init__(self, parent, main):52 def __init__(self, parent, main):
5353
=== added file 'xlgui/prefs/collection_prefs.py'
--- xlgui/prefs/collection_prefs.py 1970-01-01 00:00:00 +0000
+++ xlgui/prefs/collection_prefs.py 2009-10-04 12:40:23 +0000
@@ -0,0 +1,66 @@
1# Copyright (C) 2009 Thomas E. Zander
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 1, or (at your option)
6# any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16
17from xlgui.prefs import widgets
18from xl import xdg
19from xl.nls import gettext as _
20from xlgui import commondialogs
21
22name = _('Collection')
23ui = xdg.get_data_path('ui/collection_prefs_pane.glade')
24
25def _get_default_strip_list():
26 #TRANSLATORS: Alter default_strip_list
27 default_strip_list = _("el l' la le les los the")
28 return [v.lower() for v in default_strip_list.split(' ') if v is not '']
29
30class CollectionStripArtistPreference(widgets.ListPrefsItem):
31 default = _get_default_strip_list()
32 name = 'collection/strip_list'
33
34 def __init__(self, prefs, widget):
35 widgets.ListPrefsItem.__init__(self, prefs, widget)
36 self.widget.connect('populate-popup', self._populate_popup_cb)
37
38 def _get_value(self):
39 """
40 Get the value, overrides the base class function
41 because we don't need shlex parsing. We actually
42 want values like "l'" here.
43 """
44 values = [v.lower() for v in self.widget.get_text().split(' ') if v is not '']
45 return values
46
47 def _populate_popup_cb(self, entry, menu):
48 import gtk
49 entry = gtk.MenuItem(_('Reset to defaults'))
50 entry.connect('activate', self._reset_to_defaults_cb)
51 entry.show()
52
53 sep = gtk.SeparatorMenuItem()
54 sep.show()
55
56 menu.attach(entry, 0, 1, 0, 1)
57 menu.attach(sep, 0, 1, 1, 2)
58
59 def _reset_to_defaults_cb(self, item):
60 self.widget.set_text(' '.join(_get_default_strip_list()))
61
62class FileBasedCompilationsPreference(widgets.CheckPrefsItem):
63 default = True
64 name = 'collection/file_based_compilations'
65
66# vim:ts=4 et sw=4
067
=== modified file 'xlgui/prefs/widgets.py'
--- xlgui/prefs/widgets.py 2009-09-06 17:55:16 +0000
+++ xlgui/prefs/widgets.py 2009-10-04 12:40:23 +0000
@@ -684,6 +684,7 @@
684 def _get_value(self):684 def _get_value(self):
685 # shlex is broken with unicode, so we feed it UTF-8 and decode685 # shlex is broken with unicode, so we feed it UTF-8 and decode
686 # afterwards.686 # afterwards.
687 import shlex
687 values = shlex.split(self.widget.get_text())688 values = shlex.split(self.widget.get_text())
688 values = [unicode(value, 'utf-8') for value in values]689 values = [unicode(value, 'utf-8') for value in values]
689 return values690 return values