Remove t() from all schema descriptions

webchick - November 9, 2008 - 16:21
Project:Drupal
Version:6.x-dev
Component:database system
Category:task
Priority:normal
Assigned:Unassigned
Status:closed
Issue tags:Needs Documentation, Quick fix
Description

Split off from http://drupal.org/node/329998#comment-1099076.

In Szeged, we had a big long discussion about t() around the schema descriptions and it was the consensus of everyone at the table (who included Dries) that t()s should be removed from these descriptions. They mess up things because t() isn't available that early, and people discussed that no one is going to take the time to translate technical descriptions of stuff, and it doesn't really make sense since we also don't translate code comments, for example.

Hopefully someone can script this up so it's not too horrible. :)

#1

lilou - November 11, 2008 - 21:37
Status:active» needs review

It should be clean.

AttachmentSize
issue-332123-D7.patch 165.12 KB
Testbed results
issue-332123-D7.patchfailedFailed: Invalid PHP syntax. Detailed results

#2

lilou - November 11, 2008 - 21:43

replace also multiline (in simpletest.install) :

        'description' => t('Primary Key: Unique simpletest ID used to group test results together. Each time a set of tests
                            are run a new test ID is used.'),

AttachmentSize
issue-332123-D7.patch 165.57 KB
Testbed results
issue-332123-D7.patchfailedFailed: Invalid PHP syntax. Detailed results

#3

swentel - November 11, 2008 - 21:49

Errors in color.install - where t() shouldn't be removed , this is for the requirements, nothing todo with schema iirc

#4

lilou - November 11, 2008 - 22:21

undo color.install.

#5

lilou - November 11, 2008 - 22:15

Undo two wrong replacements in book.install and forum.install.

AttachmentSize
issue-332123-5-D7.patch 162.29 KB

#6

swentel - November 11, 2008 - 22:22

while we're at it, php install and color install use t() but they should rather use $t = get_t() like other modules do I think. Can someone else confirm that ?

#7

Anonymous (not verified) - November 14, 2008 - 03:35
Status:needs review» needs work

The last submitted patch failed testing.

#8

lilou - November 15, 2008 - 01:44
Status:needs work» needs review

Reroll.

AttachmentSize
issue-332123-8-D7.patch 162.29 KB
Testbed results
issue-332123-8-D7.patchfailedFailed: Failed to apply patch. Detailed results

#9

Dries - November 15, 2008 - 13:01
Status:needs review» needs work

Looks good. Committed to CVS HEAD. We should document this on the module upgrade page. After it has been documented, please mark this 'fixed'. Thanks!

#10

lilou - November 15, 2008 - 18:00

I haven't permission for edit page http://drupal.org/node/224333.

  1. Schema descriptions are no longer translated

Schema descriptions are no longer translated

(Issue) To reduce the strings to translate, descriptions of the schema database (tables and fields) in module.install no longer need to be translated.

6.x:

<?php
function forum_schema() {
 
$schema['forum'] = array(
   
'description' => t('Stores the relationship of nodes to forum terms.'),
   
'fields' => array(
     
'nid' => array(
       
'description' => t('The {node}.nid of the node.'),
      ),
    ),
  );
  return
$schema;
}
?>

7.x:

<?php
function forum_schema() {
 
$schema['forum'] = array(
   
'description' => 'Stores the relationship of nodes to forum terms.',
   
'fields' => array(
     
'nid' => array(
       
'description' => 'The {node}.nid of the node.',
      ),
    ),
  );
  return
$schema;
}
?>

AttachmentSize
htm-schema-translation.txt 1022 bytes

#11

webchick - November 15, 2008 - 19:41

@lilou: that horrible bug has now been fixed. Welcome to the documentation team. ;) Please feel free to add in your edits, which look great.

#12

lilou - November 15, 2008 - 22:02
Status:needs work» fixed

Thx.

#13

swentel - November 22, 2008 - 17:13
Status:fixed» needs work

block.install still needs some love - Let's look at others too. Noticed this thanks to #337794: PostgreSQL surge #1: make simpletest works again

#14

lilou - November 22, 2008 - 20:18
Status:needs work» needs review

You're right.

AttachmentSize
issue-33213-14.patch 8.21 KB
Testbed results
issue-33213-14.patchpassedPassed: 7483 passes, 0 fails, 0 exceptions Detailed results

#15

webchick - November 22, 2008 - 21:21
Status:needs review» fixed

Thanks; committed!

#16

Pasqualle - November 24, 2008 - 11:35
Status:fixed» postponed (maintainer needs more info)

Actually the schema descriptions are all translated for D6, and also translated for contributed modules (which are translated already).

I agree, that translating these strings is meaningless. My question (1) is can I file issues for D6 contributed modules to remove t() from schema descriptions? That would make module translation much more easier, and if we translate D6 modules, then removing this option in D7 just does not seem right.

And also (2) can I file an issue for potx module, to not extract scheme descriptions from D6 and D6 modules?

#17

Pasqualle - November 24, 2008 - 11:47

#18

Pasqualle - November 24, 2008 - 12:21

so, it seems like we will have to backport this patch to D6 (read the potx issue)

#19

hass - November 28, 2008 - 00:09

I can only guess how many hours I've spend on the German translation of schema translation in D& and now all this translations are going to be lost.

#20

Gábor Hojtsy - November 29, 2008 - 19:19
Version:7.x-dev» 6.x-dev
Status:postponed (maintainer needs more info)» patch (to be ported)

I've translated most of the Hungarian schema strings just to see that the translation is 100%, not to say that it will be ever read, or that it would not go against storing the descriptions in the database as table comments. I am in support of a backport.

#21

Gábor Hojtsy - November 30, 2008 - 18:34

Summarizing reasons to remove t() for hass, since he does not yet get it (see http://drupal.org/node/338409#comment-1131476):

- the functionality behind t() is not available when the schema hooks are invoked in the installer, up until locale module is enabled, so the t() calls always return the same string in installation time
- this text is documenting the code, and therefore is similar to code comments, which are not translated either
- this is technical text, and many of the translation teams such as the Hungarian team translates it just to see 100% completed translations, not because it will ever show on the interface
- if t() is not used on these strings, Drupal can actually add the descriptions to the tables and fields themselves in the database (for those backends where this is supported, for example MySQL - http://dev.mysql.com/doc/refman/5.1/en/create-table.html), so more powerful database tools can operate with those, show and help database admins to work with the tables

#22

hass - November 30, 2008 - 20:31

You missed to say that Schema module shows the translated strings in UI.

#23

Gábor Hojtsy - December 1, 2008 - 07:56

It does not need to.

#24

andypost - December 8, 2008 - 04:31

Schema field descriptions possible used in views, isn't it?
If no, suppose, t() for schema in 6x is useless.

#25

andypost - December 8, 2008 - 06:35

Another opinions to remove t()
- less runtime memory usage
- faster serialize|unserialize for locale cache

because most of descriptions less then 75 chars so they stored in locale cache but useless in production env

#26

andypost - December 9, 2008 - 02:10
Status:patch (to be ported)» needs review

Every *.install in modules checked and cleared hook_schema t()

AttachmentSize
t6_remove.patch 158.2 KB

#27

andypost - December 11, 2008 - 06:38

Chasing 6-dev

AttachmentSize
t_remove_d6.patch 158.3 KB

#28

hass - January 3, 2009 - 12:29
Status:needs review» reviewed & tested by the community

Code applies cleanly, Codewise also good and tested on dev machine with all core modules enabled.

#29

Gábor Hojtsy - January 6, 2009 - 15:58
Status:reviewed & tested by the community» fixed

Committed to Drupal 6, thanks!

Also updated docs at http://drupal.org/node/322731 to say:

One notable case in installer code is hook_schema(), which runs at install time, but Drupal core (up until Drupal 6.9) and contributed modules alike used t() for descriptions of tables and fields. The reason for that is that the Drupal installer itself does not use these strings, so it is not bothered with it not being translated while used in the installer. The contributed schema module uses these strings to help you understand the database structure. Drupal 7 changed this practice to not use t() at all in schema descriptions for various reasons (see http://drupal.org/node/332123 for more information). Therefore to save translators from pouring work into something they will entirely loose later (and help website performance as well as other good reasons), Drupal 6.9 does not use t() on these strings anymore. You should include schema strings as verbatim strings without wrapping them in localization code.

<?php
/**
* Implementation of hook_schema() to demonstrate that t() is not used.
*/
function example_schema() {
 
$schema['example_table'] = array(
   
'description' => 'This table stores example stuff.',
   
'fields' => array(
     
'eid' => array(
       
'description' => 'Example identifier.',
       
'type' => 'serial',
       
'not null' => TRUE,
      ),
     
'value' => array(
       
'description' => 'Value of the example. Can be a string or a serialized array.',
       
'type' => 'text',
       
'not null' => TRUE
     
)
    ),
   
'primary key' => array('eid'),
  );
  return
$schema;
}
?>

#30

kkaefer - January 7, 2009 - 14:45

Yay! This was really frustrating to translate.

#31

System Message - January 21, 2009 - 14:50
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

#32

quicksketch - February 28, 2009 - 00:22
Status:closed» needs work

We need to update more documentation on this. All the examples of hook_schema still include this code.

http://api.drupal.org/api/function/hook_schema
http://drupal.org/node/146843

#33

John Morahan - May 7, 2009 - 14:33

I changed http://drupal.org/node/146862 - didn't find any other examples of descriptions in that section of the handbook.
http://api.drupal.org/api/function/hook_schema is still wrong, including the D7 version

#34

quicksketch - May 20, 2009 - 19:53
Status:needs work» needs review

Could we get this committed to HEAD? Then we can do the same to the D6 version (which is still in contrib, so I can get it).

AttachmentSize
hook_schema_remove_t_docs.patch 1.88 KB

#35

webchick - May 20, 2009 - 19:56
Status:needs review» fixed

Committed. Thanks!

#36

webchick - May 20, 2009 - 19:58
Status:fixed» patch (to be ported)

Or, well.

#37

quicksketch - May 20, 2009 - 19:59
Status:patch (to be ported)» fixed

Fixed in D6 http://drupal.org/cvs?commit=214280

Thanks webchick!

#38

System Message - June 3, 2009 - 20:00
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.