t() API documentation
Hello, t() API documentation reads "Avoid escaping quotation marks wherever possible". Below is the snippet from http://api.drupal.org/api/drupal/includes--common.inc/function/t/6 Incorrect: <?php $output .= t('Don\'t click me.'); ?> Correct: <?php $output .= t("Don't click me."); ?> However the core user module's hook_block implementation is following incorrect style. The same is the case with D7 user module as well. I think the purpose of avoiding t('Don\'t click me.'); style is just to make it more readable and easier for translation. Is there any reasons for encouraging incorrect style in core. Please enlighten me on this. -- Sivaji +91 9941 571 690
Hi, The main point is that it makes it easier to grep/find the source strings in code, and figure out additional information on where are they used. It is not a critical thing but can be very helpful. Gábor On Tue, Feb 15, 2011 at 10:55 AM, sivaji j.g <sivaji2009@gmail.com> wrote:
Hello,
t() API documentation reads "Avoid escaping quotation marks wherever possible".
Below is the snippet from http://api.drupal.org/api/drupal/includes--common.inc/function/t/6
Incorrect: <?php $output .= t('Don\'t click me.'); ?>
Correct: <?php $output .= t("Don't click me."); ?>
However the core user module's hook_block implementation is following incorrect style. The same is the case with D7 user module as well.
I think the purpose of avoiding t('Don\'t click me.'); style is just to make it more readable and easier for translation.
Is there any reasons for encouraging incorrect style in core. Please enlighten me on this.
-- Sivaji +91 9941 571 690
Gábor Hojtsy wrote:
Hi,
The main point is that it makes it easier to grep/find the source strings in code, and figure out additional information on where are they used. It is not a critical thing but can be very helpful.
And patches to fix style issues in core are accepted in the issue queue. It just won't be high on the priority but simple style patches are easy to review. -- Earnie -- http://progw.com -- http://www.for-my-kids.com
Gábor Hojtsy wrote:
Hi,
The main point is that it makes it easier to grep/find the source strings in code, and figure out additional information on where are they used. It is not a critical thing but can be very helpful.
Indeed. Thanks for clarifying.
-- Sivaji +91 9941 571 690
participants (3)
-
Earnie Boyd -
Gábor Hojtsy -
sivaji j.g