[Padre-dev] l10n & plugins
Jerome Quelin
jquelin at gmail.com
Fri Apr 24 05:32:20 PDT 2009
On 09/04/21 10:36 +0200, Jerome Quelin wrote:
> questions regarding localization: plugins are not apps of their own,
> they live inside padre. hence, gettext is going to look inside padre's
> .mo files to find a translation at runtime.
>
> so, what should we do? can we instruct gettext() to look in more than
> one catalog? (and thus extend plugin api a bit) otherwise, should we
> update the pot generation to take plugins into account? if yes, does it
> mean that all plugins should be in padre's svn?
i had a look, and in fact it is possible to add other catalogs:
$locale->AddCatalogLookupPathPrefix($locale_dir);
$locale->AddCatalog("SpellCheck-fr-fr");
this works correctly.
the question is of course how to make it fit nicely with plugins. the
easy answer is of course for the plugins to define a new method:
plugin_locale_dir();
this method would return the directory where to find the plugin
catalogs. and then we AddCatalog() with the short name of the plugin,
with the current locale.
but then, the tricky question: where should we add those catalogs? we
have 2 options:
- in the Padre::Locale module
- when un/loading a plugin
the first option is nice, since we could put everything locale related
in its module. so i tried to put that in the object() method of
padre::locale. but it doesn't work, since for the first object() call
(during padre startup), the plugin manager doesn't contain any
plugins yet...
the second option might be better, since we would not add the catalogs
for plugins currently disabled. (in practice, i don't think it matters
that much). the problem comes when we want to relocale the application:
we should also relocale all the plugins (or at least, the plugin
handlers). but in fact, maybe it's the only sensible way to do it, since
plugins might need to do stuff in order to be properly relocalized.
so, what do you think? if you agree with option 2, i would then:
- introduce an official plugin_locale_dir() in plugin api
- update _load_plugin() / _unload_plugin() of padre::pluginmanager to
call addcataloglookuppathprefix() and addcatalog()
- update padre::wx::main::relocale() to also call a new method
padre::pluginmanager::relocale() which would in turn call relocale()
defined by the plugin (if this method exists)
hum, in fact addcataloglookuppathprefix() should only be called once per
plugin. but that's implementation details.
wdyt?
jérôme
--
jquelin at gmail.com
More information about the Padre-dev
mailing list