[translations] determining correct import

Jakub Suchy jakub at rtfm.cz
Sun Feb 4 19:02:23 UTC 2007


> 100% was imported). We need some fallback or determine a way how to
> speed up the process (cron?)

I was thinking about options and so far i have found two, both BAD.
Ideas please?

In both cases, we determine files needed to be imported and we store
their names into database/session/whatever. Pseudo-table:
id | filename                     | lang
1  | modules/node/po/node.cs.po   | cs
2  | modules/forum/po/forum.cs.po | cs
3  | modules/comment/...          | cs

Current approach is:
foreach ($files as $file) {
  // import file
}

One enhancement should be:
@ini_set('max_execution_time', 120); // or different number
@ini_set('memory_limit_or_whatever_the_name_is', '64M'); // or different number
This is forbidden on many hosts, but should help sometimes. AFAIK PHP5.2
or Suhosin patch allows setting longer execution time in some cases.

First VERY BAD solution may be using cron for importing files. One file
per cron run. Very slow, very ineffective, very confusing. I don't like
it

Second solution may be:
(Assuming /import.php is the script)

import.php:
// pseudocode
list($id, $file) = db_query("SELECT id, filename FROM pseudotable ORDER BY id ASC LIMIT 1");
if (!$id) {
 Header('Location: ...?ok-imported');
}
import_file($file);
remove_file_from_db($id);
Header('Location: /import.php');

This will redirect and loop import.php until all files are processed.
This is BAD solution, but can't think of better one now. Anyone?

Jakub


More information about the translations mailing list