Download & Extend

There should be no variables in the first parameter to t()

Project:Content Management Filter
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:TheRec
Status:closed (fixed)

Issue Summary

Hello,

Error issued by potx module when extracting translatable string for CMF.

The first parameter to t() should be a literal string. There should be no variables, concatenation, constants or other non-literal strings there. At t($string,array('%a'=>$filters[$type]['title'],'%b'=>$value)) in cmf.module on line 185. Read more at http://drupal.org/node/322732
The
first parameter to t() should be a literal string. There should be no variables, concatenation, constants or other non-literal strings there. At t($string,array('%a'=>$filters[$type]['title'],'%b'=>$value)) in cmf.module on line 191. Read more at http://drupal.org/node/322732

This leads to this patch with simply reuse the code in /module/node/node.admin.inc. I removed the useless condition which was also using some variable named $true and was not set anywhere in the script (which is somewhat a good thing, I wouldn't call this a good variable name :)) and in the end both branches of this condition were doing exactly the same thing... most likely something left out after tests, so I figured why not remove it.

I also modified the hook_help, where the help text was split on multiple lines which produced useless strings in the locale tables. Ah and I also put these strings in double quotes to avoid useless string caused by the escaped single quote (It\'s an ...) and made the string different than the one retrieved in the module .info file
Those bugs appeared to me while trying to build a French translation for the CMF module, which I will post when the above issues are commited.

AttachmentSize
cmf-no_var_in_translation.patch2.56 KB

Comments

#1

My bad, the escaped single quote wasn't causing any useless string in locale (this sentence is not present in .info). Anyways I feel it is a better approach when passing a string with single quotes through t(). If it is strongly against your coding standards, we can always change this again...but the multiple lines really produce useless strings in locale tables.

#2

Assigned to:Anonymous» TheRec

#3

Status:needs review» needs work

$true is passed as a parameter to the function. It probably should be something more like "$user_prof" according to the comments.

#4

Help change: See patch in #517880-1: Coding standards

#5

What is wrong with the patch is supplied ? I remember testing it and it was working and there was not more warning from potx ;)

#6

I understand. However, you delete the test for $true, which is a parameter passed in the call to the function.

#7

Status:needs work» reviewed & tested by the community

My apologies, after closer examination you are correct.

This is also included in #517880: Coding standards.

#8

Status:reviewed & tested by the community» fixed

Committed to both -dev versions. Thanks for the patch.

#9

Status:fixed» closed (fixed)

Included in new release.