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
1=== added file 'data/ui/collection_prefs_pane.glade'
2--- data/ui/collection_prefs_pane.glade 1970-01-01 00:00:00 +0000
3+++ data/ui/collection_prefs_pane.glade 2009-10-04 12:40:23 +0000
4@@ -0,0 +1,70 @@
5+<?xml version="1.0"?>
6+<interface>
7+ <requires lib="gtk+" version="2.16"/>
8+ <!-- interface-naming-policy project-wide -->
9+ <object class="GtkWindow" id="prefs_window">
10+ <child>
11+ <object class="GtkVBox" id="prefs_pane">
12+ <property name="visible">True</property>
13+ <property name="border_width">3</property>
14+ <child>
15+ <object class="GtkHBox" id="box1">
16+ <property name="visible">True</property>
17+ <property name="border_width">0</property>
18+ <child>
19+ <object class="GtkLabel" id="strip_list_label">
20+ <property name="label" translatable="yes">Strip these words from the beginnng of the artist tag (space separated):</property>
21+ <property name="receives_default">False</property>
22+ <property name="wrap">True</property>
23+ </object>
24+ <packing>
25+ <property name="expand">False</property>
26+ <property name="fill">False</property>
27+ <property name="position">0</property>
28+ </packing>
29+ </child>
30+ </object>
31+ <packing>
32+ <property name="expand">False</property>
33+ <property name="fill">False</property>
34+ <property name="position">0</property>
35+ </packing>
36+ </child>
37+ <child>
38+ <object class="GtkEntry" id="collection/strip_list">
39+ <property name="receives_default">False</property>
40+ </object>
41+ <packing>
42+ <property name="expand">False</property>
43+ <property name="fill">False</property>
44+ <property name="position">1</property>
45+ </packing>
46+ </child>
47+ <child>
48+ <object class="GtkLabel" id="collection/strip_list_label2">
49+ <property name="label" translatable="yes">(Right click for reset to defaults)</property>
50+ <property name="receives_default">False</property>
51+ </object>
52+ <packing>
53+ <property name="expand">False</property>
54+ <property name="fill">False</property>
55+ <property name="position">2</property>
56+ </packing>
57+ </child>
58+ <child>
59+ <object class="GtkCheckButton" id="collection/file_based_compilations">
60+ <property name="label" translatable="yes">Use file based compilation detection</property>
61+ <property name="visible">True</property>
62+ <property name="can_focus">True</property>
63+ <property name="receives_default">False</property>
64+ </object>
65+ <packing>
66+ <property name="expand">False</property>
67+ <property name="fill">False</property>
68+ <property name="position">3</property>
69+ </packing>
70+ </child>
71+ </object>
72+ </child>
73+ </object>
74+</interface>
75
76=== modified file 'po/de.po'
77--- po/de.po 2009-09-24 16:42:31 +0000
78+++ po/de.po 2009-10-04 12:40:23 +0000
79@@ -1160,6 +1160,10 @@
80 msgid "Shortcut"
81 msgstr "Tastenkürzel"
82
83+#: ../xlgui/prefs/collection_prefs.py:27
84+msgid "el l' la le les los the"
85+msgstr "el l' la le les los the der die das"
86+
87 #: ../xlgui/tray.py:75
88 msgid "Exaile Music Player"
89 msgstr "Exaile Musikwiedergabe"
90
91=== modified file 'xl/common.py'
92--- xl/common.py 2009-09-08 18:29:32 +0000
93+++ xl/common.py 2009-10-04 12:40:23 +0000
94@@ -310,7 +310,10 @@
95 sorting
96 """
97 lowered = field.lower()
98- for word in ("el ", "l'", "la ", "le ", "les ", "los ", "the "):
99+ import settings
100+ for word in settings.get_option('collection/strip_list', ''):
101+ if not word.endswith("'"):
102+ word += ' '
103 if lowered.startswith(word):
104 field = field[len(word):]
105 break
106
107=== modified file 'xlgui/prefs/__init__.py'
108--- xlgui/prefs/__init__.py 2009-09-08 16:03:10 +0000
109+++ xlgui/prefs/__init__.py 2009-10-04 12:40:23 +0000
110@@ -33,7 +33,7 @@
111 from xl import xdg
112 from xl.settings import _SETTINGSMANAGER
113 from xlgui.prefs.widgets import *
114-from xlgui.prefs import playlists_prefs, osd_prefs
115+from xlgui.prefs import playlists_prefs, osd_prefs, collection_prefs
116 from xlgui.prefs import cover_prefs, playback_prefs, appearance_prefs
117 from xlgui.prefs import plugin_prefs
118 import logging, traceback, gobject
119@@ -46,7 +46,7 @@
120 """
121
122 PAGES = (playlists_prefs, appearance_prefs, playback_prefs,
123- osd_prefs, cover_prefs)
124+ collection_prefs, osd_prefs, cover_prefs)
125 PREFERENCES_DIALOG = None
126
127 def __init__(self, parent, main):
128
129=== added file 'xlgui/prefs/collection_prefs.py'
130--- xlgui/prefs/collection_prefs.py 1970-01-01 00:00:00 +0000
131+++ xlgui/prefs/collection_prefs.py 2009-10-04 12:40:23 +0000
132@@ -0,0 +1,66 @@
133+# Copyright (C) 2009 Thomas E. Zander
134+#
135+# This program is free software; you can redistribute it and/or modify
136+# it under the terms of the GNU General Public License as published by
137+# the Free Software Foundation; either version 1, or (at your option)
138+# any later version.
139+#
140+# This program is distributed in the hope that it will be useful,
141+# but WITHOUT ANY WARRANTY; without even the implied warranty of
142+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
143+# GNU General Public License for more details.
144+#
145+# You should have received a copy of the GNU General Public License
146+# along with this program; if not, write to the Free Software
147+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
148+
149+from xlgui.prefs import widgets
150+from xl import xdg
151+from xl.nls import gettext as _
152+from xlgui import commondialogs
153+
154+name = _('Collection')
155+ui = xdg.get_data_path('ui/collection_prefs_pane.glade')
156+
157+def _get_default_strip_list():
158+ #TRANSLATORS: Alter default_strip_list
159+ default_strip_list = _("el l' la le les los the")
160+ return [v.lower() for v in default_strip_list.split(' ') if v is not '']
161+
162+class CollectionStripArtistPreference(widgets.ListPrefsItem):
163+ default = _get_default_strip_list()
164+ name = 'collection/strip_list'
165+
166+ def __init__(self, prefs, widget):
167+ widgets.ListPrefsItem.__init__(self, prefs, widget)
168+ self.widget.connect('populate-popup', self._populate_popup_cb)
169+
170+ def _get_value(self):
171+ """
172+ Get the value, overrides the base class function
173+ because we don't need shlex parsing. We actually
174+ want values like "l'" here.
175+ """
176+ values = [v.lower() for v in self.widget.get_text().split(' ') if v is not '']
177+ return values
178+
179+ def _populate_popup_cb(self, entry, menu):
180+ import gtk
181+ entry = gtk.MenuItem(_('Reset to defaults'))
182+ entry.connect('activate', self._reset_to_defaults_cb)
183+ entry.show()
184+
185+ sep = gtk.SeparatorMenuItem()
186+ sep.show()
187+
188+ menu.attach(entry, 0, 1, 0, 1)
189+ menu.attach(sep, 0, 1, 1, 2)
190+
191+ def _reset_to_defaults_cb(self, item):
192+ self.widget.set_text(' '.join(_get_default_strip_list()))
193+
194+class FileBasedCompilationsPreference(widgets.CheckPrefsItem):
195+ default = True
196+ name = 'collection/file_based_compilations'
197+
198+# vim:ts=4 et sw=4
199
200=== modified file 'xlgui/prefs/widgets.py'
201--- xlgui/prefs/widgets.py 2009-09-06 17:55:16 +0000
202+++ xlgui/prefs/widgets.py 2009-10-04 12:40:23 +0000
203@@ -684,6 +684,7 @@
204 def _get_value(self):
205 # shlex is broken with unicode, so we feed it UTF-8 and decode
206 # afterwards.
207+ import shlex
208 values = shlex.split(self.widget.get_text())
209 values = [unicode(value, 'utf-8') for value in values]
210 return values