Re: [Sugar-devel] [FEATURE] Enhanced Gettext

2010-01-11 Thread Simon Schampijer
On 01/05/2010 11:35 AM, Sayamindu Dasgupta wrote:
 Hello,

 Below is a proposal which I hope to get into Sugar 0.88. Note that
 this does not address Glucose translations.
 URL: http://wiki.sugarlabs.org/go/Features/Enhanced_Gettext

 Thanks,
 Sayamindu

Hi Sayamindu,

thanks for bringing this issue up and turning it into a Feature.

As much as I am in favor of allowing local modifications I hope that 
this will not have bad consequences for the upstream localization. 
Ideally, the translator would translate upstream at the same time and 
use the local translation only during the time the upstream package does 
not contain it yet. I am sure there are different ways, social or 
technical, to make sure local and upstream do not diverge that much, 
just thought I would bring it up.

Thanks,
Simon

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] [FEATURE] Enhanced Gettext

2010-01-05 Thread Sayamindu Dasgupta
Hello,

Below is a proposal which I hope to get into Sugar 0.88. Note that
this does not address Glucose translations.
URL: http://wiki.sugarlabs.org/go/Features/Enhanced_Gettext

Thanks,
Sayamindu

== Summary ==
Enhanced Gettext adds an extra search path for translation files for
Sugar activities. This would allow deployments to add and update
activity translations independently of the release process.

== Owner ==
* Name: Sayamindu Dasgupta
* Email: sayamindu at gmail dot com

== Current status ==
* Targeted release: 0.88
* Last updated: Jan 3, 2010
* Percentage of completion: 10%

== Detailed Description ==

Currently the translation process is tightly coupled with the release
workflow. In order to get the latest translations for a particular
activity, deployments need to either wait for the activity maintainer
make a new release, or use the language pack mechanism, which is
distribution specific, and an ugly hack at its best. This feature
would add a sugar.gettext module, which, if used by activities, will
search an alternative path (configurable via GConf) for translations
before looking into the activity directory (where the translations
present in the original release bundle exist.

== Benefit to Sugar ==
* Life becomes a lot easier for deployments who rely on a small
translator team to accomplish the job (smaller translation teams find
it more difficult to keep up with the Sugar release cycle)
* Activity maintainers do not have to worry about making new
releases to incorporate newer translations.
* See thread starting from
http://www.mail-archive.com/sugar-devel@lists.sugarlabs.org/msg10663.html

== Scope ==
* A sugar.gettext module needs to be created in sugar-toolkit (or
sugar-base ??)
* Activity authors need to do import sugar.gettext instead of
import gettext (it may make sense to keep the import sugar.gettext in
a try: block to retain backward compatibility)

== UI Design ==
N/A

== Contingency Plan ==
None necessary, revert to previous release behaviour.

== Documentation ==

* See thread starting from
http://www.mail-archive.com/sugar-devel@lists.sugarlabs.org/msg10663.html




-- 
Sayamindu Dasgupta
[http://sayamindu.randomink.org/ramblings]
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [FEATURE] Enhanced Gettext

2010-01-05 Thread Benjamin M. Schwartz
Sayamindu Dasgupta wrote:
 This feature
 would add a sugar.gettext module, which, if used by activities, will
 search an alternative path (configurable via GConf) for translations
 before looking into the activity directory (where the translations
 present in the original release bundle exist.

Can't we do this with unmodified gettext by setting the LOCALEDIR envvar?

--Ben




signature.asc
Description: OpenPGP digital signature
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [FEATURE] Enhanced Gettext

2010-01-05 Thread Benjamin M. Schwartz
Benjamin M. Schwartz wrote:
 Sayamindu Dasgupta wrote:
 This feature
 would add a sugar.gettext module, which, if used by activities, will
 search an alternative path (configurable via GConf) for translations
 before looking into the activity directory (where the translations
 present in the original release bundle exist.
 
 Can't we do this with unmodified gettext by setting the LOCALEDIR envvar?

s/LOCALEDIR/TEXTDOMAINDIR/

--Ben



signature.asc
Description: OpenPGP digital signature
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [FEATURE] Enhanced Gettext

2010-01-05 Thread Sayamindu Dasgupta
On Tue, Jan 5, 2010 at 11:03 PM, Benjamin M. Schwartz
bmsch...@fas.harvard.edu wrote:
 Benjamin M. Schwartz wrote:
 Sayamindu Dasgupta wrote:
 This feature
 would add a sugar.gettext module, which, if used by activities, will
 search an alternative path (configurable via GConf) for translations
 before looking into the activity directory (where the translations
 present in the original release bundle exist.

 Can't we do this with unmodified gettext by setting the LOCALEDIR envvar?

 s/LOCALEDIR/TEXTDOMAINDIR/

Ideally it would, but I don't think all programs/libraries honour
this. IIRC, this works reliably only for bash scripts. It may make
sense though to export the additional directory as $TEXTDOMAINDIR so
that tools which take advantage of it would be able to do so.

Thanks,
Sayamindu




-- 
Sayamindu Dasgupta
[http://sayamindu.randomink.org/ramblings]
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [FEATURE] Enhanced Gettext

2010-01-05 Thread Benjamin M. Schwartz
Sayamindu Dasgupta wrote:
 On Tue, Jan 5, 2010 at 11:03 PM, Benjamin M. Schwartz
 bmsch...@fas.harvard.edu wrote:
 Benjamin M. Schwartz wrote:
 Sayamindu Dasgupta wrote:
 This feature
 would add a sugar.gettext module, which, if used by activities, will
 search an alternative path (configurable via GConf) for translations
 before looking into the activity directory (where the translations
 present in the original release bundle exist.
 Can't we do this with unmodified gettext by setting the LOCALEDIR envvar?
 s/LOCALEDIR/TEXTDOMAINDIR/
 
 Ideally it would, but I don't think all programs/libraries honour
 this.

Sure.  The question is whether python's gettext module respects this.  If
it does, we don't have to make a python sugar.gettext module, and we don't
have to modify the activities.

If python's gettext isn't susceptible to environment variables, we can do
it using a one-line call to gettext.bindtextdomain.  We might even be able
to hide that call inside import sugar.activity to avoid modifying the
existing activities.

--Ben



signature.asc
Description: OpenPGP digital signature
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [FEATURE] Enhanced Gettext

2010-01-05 Thread Benjamin M. Schwartz
Sayamindu Dasgupta wrote:
 What I'm looking for is some sort of fallback mechanism in gettext,
 which would look for .mo files in the custom location first, and then
 in the usual location (as supplied to, say bindtextdomain())

I'm inclined to provide fallback by having Sugar synthesize a new
directory of symlinked .mo files, as a composite of the available
translation sets according to whatever rules we decide to employ.  The
activity can then be pointed to this directory with a single
bindtextdomain call.

I like this solution because (1) it minimizes the changes needed to
activities, (2) it avoids forking gettext, and (3) it leaves the very
tricky translation precedence logic in Glucose, which is where I think it
belongs.  This is especially important due to the complex interaction with
security/containerization.

--Ben



signature.asc
Description: OpenPGP digital signature
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [FEATURE] Enhanced Gettext

2010-01-05 Thread Sascha Silbe

On Tue, Jan 05, 2010 at 12:33:31PM -0500, Benjamin M. Schwartz wrote:

Can't we do this with unmodified gettext by setting the LOCALEDIR 
envvar?

s/LOCALEDIR/TEXTDOMAINDIR/
No because the default is hardcoded in Python (so no environment 
variable would get used unless explicitly passed by the activity):


sascha.si...@twin:~$ grep prefix /usr/lib/python2.5/gettext.py
_default_localedir = os.path.join(sys.prefix, 'share', 'locale')


Actually it looks like gettext.py doesn't even support multiple 
directories, so either the site-specific directory must contain _all_ 
translations (including those that are unmodified) or we need to wrap 
some of the gettext code:


def find(domain, localedir=None, languages=None, all=0):
[...]
 if localedir is None:
 localedir = _default_localedir
[...]
for lang in nelangs:
[...]
 mofile = os.path.join(localedir, lang, 'LC_MESSAGES', '%s.mo' % 
domain)



CU Sascha

--
http://sascha.silbe.org/
http://www.infra-silbe.de/

signature.asc
Description: Digital signature
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [FEATURE] Enhanced Gettext

2010-01-05 Thread Sascha Silbe

On Tue, Jan 05, 2010 at 04:05:20PM +0530, Sayamindu Dasgupta wrote:


Enhanced Gettext adds an extra search path for translation files for
Sugar activities.

+1, this would also fix SL#622. [1]


[1] http://bugs.sugarlabs.org/ticket/622

CU Sascha

--
http://sascha.silbe.org/
http://www.infra-silbe.de/

signature.asc
Description: Digital signature
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel