Hi,

I wanted to activate the comment filtering on the settings page (admin/settings/spam), checked the box, clicked save but it wasn't saved.

After a small investigation, I discovered that the input value attribute of the check box is "spam_filter_Kommentare" (it's the German translation for comments). So, obviously, the system wouldn't be able to save the value within the correct variable.

I looked at the source code and found something who seems odd to me in the
return (variable_get("spam_filter_$arg1->type", 0));
(line 72 of spam_node.inc)

CommentFileSizeAuthor
#3 spam-translation_fix-p0.patch3.2 KBgnassar

Comments

gnassar’s picture

Assigned: Unassigned » gnassar

I think you likely spotted the problem correctly. Thank you! I'll be looking at this in the next couple of days. I know it's been a while, so if you happen to have a patch you've already tried, please throw it on here and I'll look to roll it in.

gnassar’s picture

I think you likely spotted the problem correctly. Thank you! I'll be looking at this in the next couple of days. I know it's been a while, so if you happen to have a patch you've already tried, please throw it on here and I'll look to roll it in.

gnassar’s picture

Status: Active » Needs review
StatusFileSize
new3.2 KB

We were inconsistently translating things like module names in the include files; internal naming of modules should probably never be run through t() like we were doing. Patch enclosed.

AlexisWilke’s picture

I'm not too sure that this change is valid:

         $types[] = array(
           'name' => $type->type,
           'module' => $type->module,
-          'title' => $type->name,
-          'description' => $type->description,
+          'title' => t($type->name),
+          'description' => t($type->description),
           'default_value' => 0,
         );
       }

Core doesn't seem to ever apply t() to the name and description of a node type. (which I think is why they have that separate translation module.)

There is one exampled in modules/node/node.module around line 1737:

    $items['node/add/'. $type_url_str] = array(
      'title' => drupal_ucfirst($type->name),
      'title callback' => 'check_plain',
      'page callback' => 'node_add',
      'page arguments' => array(2),
      'access callback' => 'node_access',
      'access arguments' => array('create', $type->type),
      'description' => $type->description,
      'file' => 'node.pages.inc',
    );

Thank you.
Alexis

gnassar’s picture

That was done for consistency. If you notice our other content type modules, they all t() their names and descriptions.

The reason this is done is because the function call is substantively different from the calls you're noting in the core modules. Those are defining menu items and other such system-wide items. We're simply enumerating options to go into a checkbox list.

Though I did it for consistency, I guess we could just change all the content types to return straight strings and t() the strings in node.module -- the end result would be the same. Do you have a preference?

AlexisWilke’s picture

Ah! Good point! The menu actually does the t() call for you on the name... so I guess I'm wrong on that one. However, I do not think they do it on the description.

In general, I think it is better to allow for translations. I was just surprised by the addition of a couple t() calls. I don't know the code as well as you and did not know that the other sub-include were using it already.

I think that the current patch is fine then.

Thank you.
Alexis

gnassar’s picture

zeropaper, could you possibly test this patch and make sure you don't see any unintended side effects?

AlexisWilke’s picture

Gnassar,

You have quite high hopes here... He posted that note in March... 8-)

Thank you.
Alexis

jeremy’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me.

gnassar’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)
Issue tags: -admin, -settings, -variables

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