-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable gettext translation for glade dialogs. #75
Enable gettext translation for glade dialogs. #75
Conversation
Glade dialogs created by Gtk.Builder use the C library gettext interface. To enable localization for this interface, use setlocale / bindtextdomain from the python locale module.
I actually removed the call to The comment I was looking into in Python's documentation was the following:
It looks like I was wrong and I should have used |
Thanks for pointing me to the issue, I totally overlooked this. Regarding your quote from the Python docs: |
locale.bindtextdomain() is an interface to the eponymous libc function, which is GNU gettext specific and may not be provided on some systems (e.g. OSX). See: https://docs.python.org/3/library/locale.html#access-to-message-catalogs
Thanks, I appreciate the comments you wrote! So, I finally had a tried and I'm not convinced:
although I recognized it's probably less than ideal and not really documented. Could you have been running in this case where the correct locale file doesn't exist?
I don't think it should :) |
I didn't test for unsupported locales! Good idea to check for it :) Actually, it seems to be even more complicated:
So if a locale is not supported by the C library, but the catalog file is installed with sonata, we will have a mix of languages in the UI. I see two possible ways to handle this:
What do you think? |
On Tue, Mar 03, 2015 at 01:37:13PM -0800, Peter Helbing wrote:
Yeah, you are right, good catch!
I would say the second on looks better to me - at least it makes things If you decide to go this way, can you also log the problem so at least |
Provide uniform translation for both GObject / Glade strings (initialized by module locale) and Python gettext strings to prevent a mix of languages in UI strings. If a locale is provided with sonata but not generated for the C library, Python strings will be translated, but strings in Glade dialogs will not be translated. So if the initial locale.setlocale call fails, don't point Python gettext to the .mo files -- this way all strings will be left untranslated.
6fdcce4
to
628ffaf
Compare
I agree with you :) |
I did some updates on your last patch (I moved out of the exception handler the code which wasn't related to the exception, and I changed the usage of |
1.7b1 (2016-01-31) ------------------ New features '''''''''''' * redirect to the localized Wikipedia according to the user's local, instead of redirecting to the English one. multani/sonata#61 * add "Shuffle by album" multani/sonata#59 * repeat single song (Corentin Néau) multani/sonata#95 Bug fixes ''''''''' * fix crashs on Gtk.TextView when updating the lyrics of a song * Fix streams parsing: multani/sonata#41 multani/sonata#38 * fix withdrawn mode by fixing incorrect usage of threads and Gtk eco-system * choosing a local artwork wasn't working anymore * fix artwork caching * keep the selected tab when hiding/showing Sonata using the tray icon * correctly handle tracks without a definitely reasonable track or disc value (Peter Helbing) multani/sonata#74 * fix translation of of Glade dialogs (Peter Helbing) multani/sonata#75 * fix opening the About dialog (based on Rocus van Oosten report). * fix refreshing profiles upon connections add/delete (Corentin Néau) multani/sonata#92 * fix update of cover and text in fullscreen mode (Corentin Néau) multani/sonata#93 Internal changes '''''''''''''''' * slightly better performance when updating the library * threading improvements: - use GIO instead of a thread to download drag-and-droped covers - remove the MPD from a dedicated thread. It works as good (if not better) as before since the threaded code was poorly written anyway and rendered the additionnal basically useless. This move is not definitive but something better will probably come up some day. * Looking for covers isn't as filesystem expensive as before, but it doesn't check for multiple possible cases in the cover name anymore. 1.7a2 (2013-11-26) ------------------ New features '''''''''''' * Download bigger covers from Last.fm * Centering the current song using Ctrl+i now also selects the current song * Use Transifex as a translation plateform. See https://www.transifex.com/projects/p/sonata/ * Update translations: - Russian (thanks Stas!) - Ukrainian (thanks Stas!) - French (thanks Jon!) Bug fixes ''''''''' * Fix search in library (using a specific filter or the 'everything' filter) * Fix scrobbling to Last.fm * Scrolling with the mouse wheel on the tray icon correctly changes the volume * Some lyrics from LyricsWiki redirects to another page. The plugin now follows those redirect to find the actual lyrics. * Fix multiple issues related to drag-and-drop of songs in the current playlist * Fix error while using Sonata's command line interface * Fix filtering songs in the current playlist * Fix DND of custom artwork images in the main window * Fix breadcrumb icon in the library while browsing an album while in Artist view * Fix saving the visibility flag of tabs: multani/sonata#45 * Fix hiding/showing the main window even if it's not the active widget: multani/sonata#43 * Deleting a track doesn't toggle the filter bar anymore in the current playlist. * Better support for MPD 0.18 Internal changes '''''''''''''''' * Simplified the `current` module. It should also now use less memory than before. * Provide a new GObject signal to notify on artwork change and artwork reset. 1.7a1 (2013-02-08) ------------------ New features '''''''''''' * Fetch covers from Last.fm instead of Rhapsody.com * Custom plugins are now stored along the configuration file in ~/.config/sonata/plugins/ * Switch to Python 3 and Gtk 3 (Jörg Thalheim & Adam Dane) * More items in the tray menu (Kirill Lashuk) * Better fullscreen support (Kirill Lashuk) * Toggle fullscreen from the command line (Daniel) * Support MPD's "consume" mode (Anton Lashkov) * Use more default icons in the context menus (Anton Lashkov) * Load only the most recent of plugins with the same names Bug fixes ''''''''' * Fix population of the "Save to playlist" menu (Zhihao Yuan) * Prevent multiple entries and improve art search with multi-CD albums (Kirill Lashuk) * Fixes weird show up if Sonata is not on the current workspace (Kirill Lashuk) * Scrobble after seeking to the beginning (Kirill Lashuk) * The lyricswiki plugin should now work again (Jonathan Ballet) * Fix UI status after reconnection to MPD (Jonathan Ballet) * Fix crash when searching the library (Kirill Lashuk) Internal changes '''''''''''''''' * Simpler API for cover fetching plugins * Lot of code cleanup and internal changes * Removed Sugar UI support * Use Glade files to describe the interface and GtkBuilder to build the interface * More systematic configuration file management * High-level access to MPD's command results
1.7b1 (2016-01-31) ------------------ New features '''''''''''' * redirect to the localized Wikipedia according to the user's local, instead of redirecting to the English one. multani/sonata#61 * add "Shuffle by album" multani/sonata#59 * repeat single song (Corentin Néau) multani/sonata#95 Bug fixes ''''''''' * fix crashs on Gtk.TextView when updating the lyrics of a song * Fix streams parsing: multani/sonata#41 multani/sonata#38 * fix withdrawn mode by fixing incorrect usage of threads and Gtk eco-system * choosing a local artwork wasn't working anymore * fix artwork caching * keep the selected tab when hiding/showing Sonata using the tray icon * correctly handle tracks without a definitely reasonable track or disc value (Peter Helbing) multani/sonata#74 * fix translation of of Glade dialogs (Peter Helbing) multani/sonata#75 * fix opening the About dialog (based on Rocus van Oosten report). * fix refreshing profiles upon connections add/delete (Corentin Néau) multani/sonata#92 * fix update of cover and text in fullscreen mode (Corentin Néau) multani/sonata#93 Internal changes '''''''''''''''' * slightly better performance when updating the library * threading improvements: - use GIO instead of a thread to download drag-and-droped covers - remove the MPD from a dedicated thread. It works as good (if not better) as before since the threaded code was poorly written anyway and rendered the additionnal basically useless. This move is not definitive but something better will probably come up some day. * Looking for covers isn't as filesystem expensive as before, but it doesn't check for multiple possible cases in the cover name anymore. 1.7a2 (2013-11-26) ------------------ New features '''''''''''' * Download bigger covers from Last.fm * Centering the current song using Ctrl+i now also selects the current song * Use Transifex as a translation plateform. See https://www.transifex.com/projects/p/sonata/ * Update translations: - Russian (thanks Stas!) - Ukrainian (thanks Stas!) - French (thanks Jon!) Bug fixes ''''''''' * Fix search in library (using a specific filter or the 'everything' filter) * Fix scrobbling to Last.fm * Scrolling with the mouse wheel on the tray icon correctly changes the volume * Some lyrics from LyricsWiki redirects to another page. The plugin now follows those redirect to find the actual lyrics. * Fix multiple issues related to drag-and-drop of songs in the current playlist * Fix error while using Sonata's command line interface * Fix filtering songs in the current playlist * Fix DND of custom artwork images in the main window * Fix breadcrumb icon in the library while browsing an album while in Artist view * Fix saving the visibility flag of tabs: multani/sonata#45 * Fix hiding/showing the main window even if it's not the active widget: multani/sonata#43 * Deleting a track doesn't toggle the filter bar anymore in the current playlist. * Better support for MPD 0.18 Internal changes '''''''''''''''' * Simplified the `current` module. It should also now use less memory than before. * Provide a new GObject signal to notify on artwork change and artwork reset. 1.7a1 (2013-02-08) ------------------ New features '''''''''''' * Fetch covers from Last.fm instead of Rhapsody.com * Custom plugins are now stored along the configuration file in ~/.config/sonata/plugins/ * Switch to Python 3 and Gtk 3 (Jörg Thalheim & Adam Dane) * More items in the tray menu (Kirill Lashuk) * Better fullscreen support (Kirill Lashuk) * Toggle fullscreen from the command line (Daniel) * Support MPD's "consume" mode (Anton Lashkov) * Use more default icons in the context menus (Anton Lashkov) * Load only the most recent of plugins with the same names Bug fixes ''''''''' * Fix population of the "Save to playlist" menu (Zhihao Yuan) * Prevent multiple entries and improve art search with multi-CD albums (Kirill Lashuk) * Fixes weird show up if Sonata is not on the current workspace (Kirill Lashuk) * Scrobble after seeking to the beginning (Kirill Lashuk) * The lyricswiki plugin should now work again (Jonathan Ballet) * Fix UI status after reconnection to MPD (Jonathan Ballet) * Fix crash when searching the library (Kirill Lashuk) Internal changes '''''''''''''''' * Simpler API for cover fetching plugins * Lot of code cleanup and internal changes * Removed Sugar UI support * Use Glade files to describe the interface and GtkBuilder to build the interface * More systematic configuration file management * High-level access to MPD's command results
Glade dialogs created by Gtk.Builder use the C library gettext
interface. To enable localization for this interface, use setlocale /
bindtextdomain from the python locale module.
For a detailed explanation see: https://stackoverflow.com/questions/10094335/how-to-bind-a-text-domain-to-a-local-folder-for-gettext-under-gtk3