[opensuse-factory] bundle-lang packages and python gettext don't like each other
Hi all, While debugging https://bugzilla.novell.com/show_bug.cgi?id=617751 I ran across an issue with our bundle-lang-<x>-<y> packages and the way python gettext work. In order for bundle-lang-<x>-<y> not to conflict with <package>-lang, the bundle moves the files to /usr/share/locale-bundle (as opposed to /usr/share/locale, which is the default location). For C - Programs, this seems to be all fine, and a bundle-lang being installed helps translating the program. As the above bug indicates, this did not work for system-config-printer (I can reproduce with other python apps as well, e.g gnome-tweak-tools). The issue lies in python's gettext, where you can either pass a localedir to gettext.bindtextdomain, or you can omit it (which defaults, you guess, to sys.prefix/share/locale) Now, I see several options to tackle such an issue: - Do not add -lang files of python apps to bundle-lang-<x>-<y> packages - Do not move files to /usr/share/locale-bundle - Fix pythons gettext The last one is surely most appealing, but I'm not sure who can implement it in what time-frame. First ones both have their issues, but would likely be simple to implement. So, what are your ideas and/or proposals? Best regards, Dominique -- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-factory+owner@opensuse.org
Hey, Le jeudi 02 août 2012, à 21:14 +0200, Dominique Leuenberger a écrit :
Hi all,
While debugging https://bugzilla.novell.com/show_bug.cgi?id=617751 I ran across an issue with our bundle-lang-<x>-<y> packages and the way python gettext work.
In order for bundle-lang-<x>-<y> not to conflict with <package>-lang, the bundle moves the files to /usr/share/locale-bundle (as opposed to /usr/share/locale, which is the default location).
For C - Programs, this seems to be all fine, and a bundle-lang being installed helps translating the program.
As the above bug indicates, this did not work for system-config-printer (I can reproduce with other python apps as well, e.g gnome-tweak-tools).
The issue lies in python's gettext, where you can either pass a localedir to gettext.bindtextdomain, or you can omit it (which defaults, you guess, to sys.prefix/share/locale)
Now, I see several options to tackle such an issue: - Do not add -lang files of python apps to bundle-lang-<x>-<y> packages
Workaround, probably okay for 12.2.
- Do not move files to /usr/share/locale-bundle
Baaad because of file conflicts :-)
- Fix pythons gettext
That's what we want, I guess. It seems patching the find method in gettext.py shouldn't be too hard. We could add something like: if localedir in [None, _default_localedir]: _default_bundlelocaledir = os.path.join(sys.prefix, 'share', 'locale-bundle') bundle = find(domain, localedir=_default_bundlelocaledir, languages=languages, all=all) if bundle is not None: return bundle (obviously, bonus point for declaring _default_bundlelocaledir at the top of the file, where _default_localedir is declared) Cheers, Vincent -- Les gens heureux ne sont pas pressés. -- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-factory+owner@opensuse.org
Quoting Vincent Untz
Hey,
- Fix pythons gettext
That's what we want, I guess. It seems patching the find method in gettext.py shouldn't be too hard. We could add something like:
if localedir in [None, _default_localedir]: _default_bundlelocaledir = os.path.join(sys.prefix, 'share', 'locale-bundle') bundle = find(domain, localedir=_default_bundlelocaledir, languages=languages, all=all) if bundle is not None: return bundle
(obviously, bonus point for declaring _default_bundlelocaledir at the top of the file, where _default_localedir is declared)
Note that this will require also patching most of the python apps I looked at so far: the almost all have gettext.bindtextdomain(domain,path), where path is NOT set to None for them... Just to have this noted as well. Dominique -- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-factory+owner@opensuse.org
Le vendredi 03 août 2012, à 10:40 -0400, Dominique Leuenberger a écrit :
Quoting Vincent Untz
: Hey,
- Fix pythons gettext
That's what we want, I guess. It seems patching the find method in gettext.py shouldn't be too hard. We could add something like:
if localedir in [None, _default_localedir]: _default_bundlelocaledir = os.path.join(sys.prefix, 'share', 'locale-bundle') bundle = find(domain, localedir=_default_bundlelocaledir, languages=languages, all=all) if bundle is not None: return bundle
(obviously, bonus point for declaring _default_bundlelocaledir at the top of the file, where _default_localedir is declared)
Note that this will require also patching most of the python apps I looked at so far: the almost all have gettext.bindtextdomain(domain,path), where path is NOT set to None for them...
But path should be set to _default_localedir ($prefix/share/locale) for most of them. If it's not, then the translations are not in the bundles anyway. So all should be fine. Vincent -- Les gens heureux ne sont pas pressés. -- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-factory+owner@opensuse.org
Quoting Vincent Untz
Le vendredi 03 août 2012, à 10:40 -0400, Dominique Leuenberger a écrit : fault_localedir is declared)
Note that this will require also patching most of the python apps I looked at so far: the almost all have gettext.bindtextdomain(domain,path), where path is NOT set to None for them...
But path should be set to _default_localedir ($prefix/share/locale) for most of them. If it's not, then the translations are not in the bundles anyway. So all should be fine.
* System-config-printer has: (in system-config-printer.py) from gettext import gettext as _ gettext.textdomain (config.PACKAGE) gettext.bindtextdomain (config.PACKAGE, config.localedir) * and config.py: prefix="/usr" datadir="/usr/share" localedir="/usr/share/locale" so still patchwork needed... -- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-factory+owner@opensuse.org
On Fri, 2012-08-03 at 16:36 +0200, Vincent Untz wrote:
Hey,
- Fix pythons gettext
That's what we want, I guess. It seems patching the find method in gettext.py shouldn't be too hard. We could add something like:
if localedir in [None, _default_localedir]: _default_bundlelocaledir = os.path.join(sys.prefix, 'share', 'locale-bundle') bundle = find(domain, localedir=_default_bundlelocaledir, languages=languages, all=all) if bundle is not None: return bundle
Thanks a lot Vincent! I submitted SR129866 with a fix largely based on your patch (which worked almost without modification). In my tests with the few packages I had identified before work like a charm with this fix... I'm not sure how much interest an upstream could have for such a patch (are we the only ones doing bundle-lang packages?), but I might give it a shot. Best regards, Dominique -- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-factory+owner@opensuse.org
Le vendredi 03 août 2012, à 20:59 +0200, Dominique Leuenberger a écrit :
On Fri, 2012-08-03 at 16:36 +0200, Vincent Untz wrote:
- Fix pythons gettext
That's what we want, I guess. It seems patching the find method in gettext.py shouldn't be too hard. We could add something like:
[...]
I'm not sure how much interest an upstream could have for such a patch (are we the only ones doing bundle-lang packages?), but I might give it a shot.
I think that's openSUSE-only, unfortunately. At least, other distros who are shipping bundles don't you the same directory as far as I know. Vincent -- Les gens heureux ne sont pas pressés. -- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-factory+owner@opensuse.org
participants (4)
-
Dimstar / Dominique Leuenberger
-
Dominique Leuenberger
-
Dominique Leuenberger a.k.a DimStar
-
Vincent Untz