Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I noticed that a Drupal core function is using the following code:

$categories = db_select('contact', 'c')
  ->addTag('translatable')
  ->fields('c', array('cid', 'category', 'recipients', 'selected'))
  ->orderBy('weight')
  ->orderBy('category')
  ->execute()
  ->fetchAll();

When should a module add that tag to the query it is executing?
What is the effect of adding that tag? What is effectively altered, in the query object, or in the result returned by the query?

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

On it's own, that tag doesn't much (yet).

This is the so called "Dynamic data translation" feature, the idea was born on Prepare Drupal core for dynamic data translation.

Basically, you define in your hook_schema() (See contact_schema() for an example) which fields can be translated, and then add the "translatable" tag to all queries which fetch the data. Use 'translated' => TRUE' for all such columns.

Then, what is supposed to happen is that a contributed module can maintain separate tables per language for your translatable columns, automatically join these tables, and replace the selected columns with those from translated table.

However, as far as I know, nobody has yet attempted to write such a module.

share|improve this answer
    
In that report I read that translatable fields are marked in hook_schema() with 'translatable' => TRUE. Is that correct? –  kiamlaluno Mar 23 '11 at 18:05
    
Exactly, updated the answer and added a link to contact_schema() –  Berdir Mar 23 '11 at 18:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.