[rhythmbox] context: make strings in templates translatable



commit 8d45d9251d0d5ca77f6901b3c5aaef5d57fe73f3
Author: Jonathan Matthew <jonathan fibula d14n org>
Date:   Sun Nov 1 10:16:06 2009 +1000

    context: make strings in templates translatable

 plugins/context/context/AlbumTab.py   |    4 ++--
 plugins/context/context/ArtistTab.py  |    2 +-
 plugins/context/tmpl/album-tmpl.html  |   20 +++++++++++---------
 plugins/context/tmpl/artist-tmpl.html |   12 ++++++------
 plugins/context/tmpl/loading.html     |    2 +-
 po/POTFILES.in                        |   10 ++++++++++
 6 files changed, 31 insertions(+), 19 deletions(-)
---
diff --git a/plugins/context/context/AlbumTab.py b/plugins/context/context/AlbumTab.py
index ff0ae30..c529946 100644
--- a/plugins/context/context/AlbumTab.py
+++ b/plugins/context/context/AlbumTab.py
@@ -108,7 +108,7 @@ class AlbumView (gobject.GObject):
     def loading (self, current_artist):
         self.loading_file = self.loading_template.render (
             artist   = current_artist,
-            info     = "Top Albums",
+            info     = _("Loading top albums for %s") % current_artist,
             song     = "",
             basepath = self.basepath)
         self.webview.load_string (self.loading_file, 'text/html', 'utf-8', self.basepath)
@@ -222,7 +222,7 @@ class AlbumDataSource (gobject.GObject):
                                                                  album.replace(" ", "+"),
                                                                  LastFM.API_KEY)
         self.info_cache.fetch(cachekey, url, self.fetch_album_tracklist, album, index)
-            
+
     def fetch_album_tracklist (self, data, album, index):
         if data is None:
             self.assemble_info(None, None, None)
diff --git a/plugins/context/context/ArtistTab.py b/plugins/context/context/ArtistTab.py
index dad048c..3677ac6 100644
--- a/plugins/context/context/ArtistTab.py
+++ b/plugins/context/context/ArtistTab.py
@@ -106,7 +106,7 @@ class ArtistView (gobject.GObject):
     def loading (self, current_artist):
         self.loading_file = self.loading_template.render (
             artist   = current_artist,
-            info     = "Bio",
+            info     = _("Loading biography for %s") % current_artist,
             song     = "",
             basepath = self.basepath)
         self.webview.load_string (self.loading_file, 'text/html', 'utf-8', self.basepath)
diff --git a/plugins/context/tmpl/album-tmpl.html b/plugins/context/tmpl/album-tmpl.html
index 5e9e33f..9e73068 100644
--- a/plugins/context/tmpl/album-tmpl.html
+++ b/plugins/context/tmpl/album-tmpl.html
@@ -11,9 +11,9 @@
         mn = time / 60
         sec = time % 60
         if hr > 0:
-            return "%d:%02d:%02d" % (hr,mn,sec)
+            return _("%d:%02d:%02d") % (hr,mn,sec)
         else:
-            return "%d:%02d" %(mn,sec)
+            return _("%d:%02d") %(mn,sec)
 %>  
 <link rel="stylesheet" href="${stylesheet}" type="text/css" />
 <script language="javascript">
@@ -27,7 +27,9 @@
     }
     function toggle_vis (element) { 
         swapClass(element, 'hidden', 'shown');
-        swapText('btn_'+element, 'Hide all tracks', 'Show all tracks');
+        hide = "${ _("Hide all tracks") }";
+        show = "${ _("Show all tracks") }";
+        swapText('btn_'+element, hide, show);
     }
 </script>
 </head>
@@ -36,7 +38,7 @@
 <%  
     num_albums = min(8, len(list))
 %>
-    <h1>Top albums by <em>${artist}</em></h1>
+    <h1>${ _("Top albums by %s") % ("<em>" + artist + "</em>") }</h1>
 %for i, entry in enumerate(list) :
     <%
     if 'tracklist' not in entry or len(entry['tracklist']) == 0:
@@ -52,12 +54,12 @@
         album_time = sec2hms(entry['duration'])
         tracks = len(entry['tracklist'])
     %>
-    <p class="duration">${album_time} (${tracks} tracks)</p>
+    <p class="duration">${ _("%s (%d tracks)") % (album_time, tracks) }</p>
     %endif
     %if 'tracklist' in entry:
     <% btn_name = "btn_%s" % entry['id'] %>
-    <button id="btn_${entry['id']}"onclick="toggle_vis(${entry['id']})">
-    Show all tracks
+    <button id="btn_${entry['id']}" onclick="toggle_vis(${entry['id']})">
+    ${ _("Show all tracks") }
     </button>
     <table class="hidden" id="${entry['id']}">
         %for num, title, time in entry['tracklist'] :
@@ -70,12 +72,12 @@
         %endfor
     </table>
     %else:
-    <p>Tracklist not available</p>
+    <p>${ _("Track list not available") }</p>
     %endif
     </div>
 %endfor
 %else:
-    <h1>Last.fm Error:</h1>
+    <h1>${ _("Unable to retrieve album information:") }</h1>
     <p class="error">${error}</p>
 %endif
 </body>
diff --git a/plugins/context/tmpl/artist-tmpl.html b/plugins/context/tmpl/artist-tmpl.html
index bea180a..64ff139 100644
--- a/plugins/context/tmpl/artist-tmpl.html
+++ b/plugins/context/tmpl/artist-tmpl.html
@@ -5,7 +5,7 @@
     
     def cleanup(text):
         if text is None:
-            return "No information available"
+            return _("No information available")
         text = remove_links.sub ('', text)
         text = text.replace('\n', '</p><p>')
         return text
@@ -28,23 +28,23 @@
 <div id="shortbio" class="shown">
 <% shortbio = cleanup(shortbio) %>
 <button name="more" onclick="swapClass('shortbio', 'shown', 'hidden');swapClass('fullbio', 'shown', 'hidden')" />
-Read more
+${ _("Read more") }
 </button>
 <p>${shortbio}</p>
 </div>
 <div id="fullbio" class="hidden">
 <% fullbio = cleanup(fullbio) %>
 <button name="more" onclick="swapClass('shortbio', 'shown', 'hidden');swapClass('fullbio', 'shown', 'hidden')" />
-Read less
+${ _("Read less") }
 </button>
 <p>${fullbio}</p>
 <button name="more" onclick="swapClass('shortbio', 'shown', 'hidden');swapClass('fullbio', 'shown', 'hidden')" />
-Read less
+${ _("Read less") }
 </button>
 </div>
 %else:
-<h1>Unable to retrieve artist information:</h1>
-<p class="error">${error}$</p>
+<h1>${ _("Unable to retrieve artist information:") }</h1>
+<p class="error">${error}</p>
 %endif
 </body>
 </html>
diff --git a/plugins/context/tmpl/loading.html b/plugins/context/tmpl/loading.html
index 05233ef..769d187 100644
--- a/plugins/context/tmpl/loading.html
+++ b/plugins/context/tmpl/loading.html
@@ -8,7 +8,7 @@ img { display: block; margin-left: auto; margin-right: auto }
 </style>
 </head>
 <body>
-<h1>Loading ${info} for - ${artist} ${song}</h1>
+<h1>${info}</h1>
 <img src="${basepath}/img/spinner.gif" />
 </body>
 </html>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 5548da5..e1fae99 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -55,6 +55,16 @@ plugins/cd-recorder/rb-recorder-gst.c
 plugins/cd-recorder/rb-playlist-source-recorder.c
 [type: gettext/glade]plugins/cd-recorder/recorder.ui
 [type: gettext/ini]plugins/coherence/coherence.rb-plugin.in
+[type: gettext/ini]plugins/context/context.rb-plugin.in
+plugins/context/context/AlbumTab.py
+plugins/context/context/ArtistTab.py
+plugins/context/context/ContextView.py
+plugins/context/context/LastFM.py
+plugins/context/context/LyricsTab.py
+plugins/context/tmpl/album-tmpl.html
+plugins/context/tmpl/artist-tmpl.html
+plugins/context/tmpl/loading.html
+plugins/context/tmpl/lyrics-tmpl.html
 [type: gettext/ini]plugins/daap/daap.rb-plugin.in
 [type: gettext/glade]plugins/daap/daap-prefs.ui
 plugins/daap/rb-daap-connection.c



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]