[translations] autolocale automatic installation
Gabor Hojtsy
gabor at hojtsy.hu
Fri Feb 2 22:30:13 UTC 2007
Hi Jakub,
I have done away two hours this evening with trying to come up with ways
to handle this without stuffing the module list into the session, but
was unable to do it, since the system_module handler results in a
redirect before a possible next submit handler would be able to run.
Anyway, after that two hours, I have started off from your code and
cleaned it up (ie. no need to foreach on the form array, since we can
grab it as is). Added logic to import all PO files for all enabled
languages, and comitted the result:
http://drupal.org/cvs?commit=54356
I tried to test this as much as I can, and it really seems to work.
After giving some deeper thought to this session storage method, I
figured we have no problem with it until we need to deal with modules
being disabled (which is not the case yet).
Thanks for sharing this piece of advice!
Ps. I also fixed a cache cleanup error, and a postresql compatibility
error recently in autolocale.
Gabor
Jakub Suchy wrote:
> Gabor Hojtsy wrote:
>> 1. Check the database (or the module_list()) in the early callback.
>> 2. Check it again at the callback called last.
>> 3. Compute the difference.
>> 4. Import what needs to be imported
>
> Is this clean and does it have some catch? It works for me
>
> function autolocale_form_alter($form_id, &$form) {
> // Process only if module form is displayed
> if ($form_id === "system_modules") {
>
> // Determine which modules are enabled at the moment
> if (is_array($form['status']['#default_value'])) {
> $autolocale_modules = array();
> foreach ($form['status']['#default_value'] as $module) {
> array_push($autolocale_modules, $module);
> }
>
> // We MUST skip module confirm form
> if ($_GET['q'] != "admin/build/modules/list/confirm") {
> $enabled = array_diff($autolocale_modules, $_SESSION['autolocale_modules']);
> if (!empty($enabled)) {
> // These modules have been enabled
> print_r($enabled); // TODO
> }
> }
>
> // Store modules for next reload
> $_SESSION['autolocale_modules'] = $autolocale_modules;
> }
>
> }
> }
> _______________________________________________
> translations mailing list
> translations at drupal.org
> http://lists.drupal.org/mailman/listinfo/translations
>
More information about the translations
mailing list