Drupal Association members fund grants that make connections all over the world.
While small one-line texts are not a problem, updating and translating big chunks of text is currently really difficult in Drupal:
- The texts are written in multiple lines mixed with php. It takes a php coder to fix a typo most of the times.
- The localization system performance is awful for big texts, searches are done using full source text.
- The translation process is usually quite hard because you need to translate line by line, you usually miss the context.
This (proof of concept) patch, which only takes care so far of a pair texts in the node module, introduces a new system on which big texts are stored on a text file, then retrieved when needed using a text key:
drupal_get_text('node', 'module-help', ...); drupal_get_text('node', 'welcome-page-nocontent', ..);
The single text files are searched in the filesystem, can be overridden using variables, can be localized using the locale system or a translation file can be found on the filesystem..... The proposed file system structure is as follows:
modules/node/text/module-help.html (Original English text) modules/node/translations/es/module-help.html (Spanish translation included in node file) translations/modules/node/es/module-help.html (Spanish translation in an alternate folder..)
This approach has some important advantages:
- The texts are not mixed with php code, people on the documentation team could easily update them without the risk of breaking any code.
- The handling of big texts would be much better with the localization system only doing text searches for small ones, that maybe could be cached all at once. This still needs some UI and text updating into the db
- Translators finally get to see the whole text for translating, and they translate the full text at once, not line by line like until now
- Drupal code would be much shorter, as we take this huge unreadable texts out of the php files. The text files are only loaded when needed
- It is fully compatible with the old approach, we can still use t() for small texts into the code
This could be used for most of help texts, user emails, and in general for any text longer than one line. In summary, we move from this (php file):
$default_message = '<h1 class="title">' . t('Welcome to your new Drupal website!') . '</h1>'; $default_message .= '<p>' . t('Please follow these steps to set up and start using your website:') . '</p>'; $default_message .= '<ol>'; $default_message .= '<li>' . t('<strong>Configure your website</strong> Once logged in, visit the <a href="@admin">administration section</a>, where you can <a href="@config">customize and configure</a> all aspects of your website.', array('@admin' => url('admin'), '@config' => url('admin/settings'))) . '</li>';
to this (html file):
<h1 class="title">Welcome to your new Drupal website!</h1> <p>Please follow these steps to set up and start using your website:</p> <ol> <li><strong>Configure your website</strong> Once logged in, visit the <a href="@admin">administration section</a>, where you can <a href="@config">customize and configure</a> all aspects of your website.</li> ...
Note: this patch may overlap with this one
however I think it is quite a different approach (it's not only for help texts but for all long texts) like to be on a different thread.