I just noticed that it is impossible to translate the status texts when filtering nodes in the admin section. The texts were never incorporated into the translation templates (even for 5.x and before!) because the string was passed to t() as a variable. See the screenshot (note the untranslated text on an otherwise 100% translated Drupal).

This can also be backported to 5.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kkaefer’s picture

FileSize
16.56 KB

kkaefer’s picture

Duh, I should actually syntax-check before posting...

Freso’s picture

Just curious, but is there a reason to move from foo ? bar : baz to if foo {bar} else {baz}? The t() should easily be able to go into the former test, but I don't know if there is any performance or anything to be gained either way, so, really, I'm simply curious. :)

Also, again, I'll probably test this in the morrow.

kkaefer’s picture

We have shorter and more readable lines. I am not aware of any performance penalties.

Freso’s picture

gentoo-vm drupal-cvs # patch -p0 < node-filter-translation.patch
patching file modules/user/user.module
Hunk #1 FAILED at 3123.
1 out of 1 hunk FAILED -- saving rejects to file modules/user/user.module.rej

Re-rolled to attached patch and fixed problems with parentheses. (Btw, would if (!empty($i++)) be faster than if ($i++ > 0)? See Guidelines for better performing code.)

I'm apparently having some issues with locale.module though, right now, so further testing of the patch will have to wait a wee bit.

kkaefer’s picture

Thanks for rerolling. I doubt that empty() is faster because $i++ &gt; 0 is a very basic integer comparison.

Freso’s picture

Status: Needs review » Reviewed & tested by the community

Using a patched potx-cli.php from kkaefer, I did the following:

gentoo-vm drupal6 # php potx-cli.php --files modules/user/user.admin.inc
Processing modules/user/user.admin.inc...
Invalid marker content in modules/user/user.admin.inc:56
* t($string,array('%a'=>$filters[$type]['title'],'%b'=>$options[$value]))

Invalid marker content in modules/user/user.admin.inc:525
* t($perm)

Invalid marker content in modules/user/user.admin.inc:586
* t($key)

Done.
gentoo-vm drupal6 # mv general.pot general.old.pot
gentoo-vm drupal6 # patch -p0 < node-filter-translation.patch
patching file modules/user/user.admin.inc
gentoo-vm drupal6 # php potx-cli.php --files modules/user/user.admin.inc
Processing modules/user/user.admin.inc...
Invalid marker content in modules/user/user.admin.inc:530
* t($perm)

Invalid marker content in modules/user/user.admin.inc:591
* t($key)

Done.
gentoo-vm drupal6 # mv general.pot general.new.pot
gentoo-vm drupal6 # diff -uI"^#" general.old.pot general.new.pot
--- general.old.pot 2007-09-11 21:46:54.000000000 +0200
+++ general.new.pot 2007-09-11 21:47:19.000000000 +0200
@@ -8,7 +8,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
-"POT-Creation-Date: 2007-09-11 21:46+0200\n"
+"POT-Creation-Date: 2007-09-11 21:47+0200\n"
"PO-Revision-Date: YYYY-mm-DD HH:MM+ZZZZ\n"
"Last-Translator: NAME \n"
"Language-Team: LANGUAGE \n"
@@ -29,7 +29,15 @@
msgid "Show only users where"
msgstr ""

-#: modules/user/user.admin.inc:70;91
+#: modules/user/user.admin.inc:57
+msgid "and where %property is %value"
+msgstr ""
+
+#: modules/user/user.admin.inc:60
+msgid "%property is %value"
+msgstr ""
+
+#: modules/user/user.admin.inc:75;96
msgid "Refine"
msgstr ""

gentoo-vm drupal6 #

Having previously tested the patch for b0rkage, I think it does what it says it does, without any glitches that I can see, and probably without affecting performance. Can't see why it shouldn't be RTBC.

Gábor Hojtsy’s picture

Version: 6.x-dev » 5.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Oh, I noticed this was not translated properly on some sites, but never thought that it is actually not translatable... Hm, good catch. Also lamented on the patch a bit, thinking about moving the t()s back to a ternary assignment. But it would not save much code for us, so committed this if() based version, which is a bit more clear. Thanks!

Setting for porting to 5.x. (Because a new 5.x release might hit the shelfs soon, it might be a good idea to roll this backport sooner then later).

kkaefer’s picture

Status: Patch (to be ported) » Reviewed & tested by the community

The patch from #2 is code-wise identical with the committed patch and applies to Drupal 5 with an offset of 569 lines.

drumm’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 5.x.

Anonymous’s picture

Status: Fixed » Closed (fixed)