Posted by Ali Majdzadeh K... on December 25, 2008 at 12:08pm
7 followers
| Project: | Nodequeue |
| Version: | 7.x-2.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Issue Summary
Hello
It would be nice if there was translation support for "add to queue" and "remove from queue" texts.
Kind Regards
Ali Majdzadeh Kohbanani
Comments
#1
Good point -- We should translate the custom links.
#2
Thanks, hope to see that working in future releases. By the way, thanks a lot for such a nice module.
Kind Regards
Ali Majdzadeh Kohbanani
#3
#4
Yeah, would be great to have these translatable.
I'm no php developer but here are some pointers on how to do this:
http://drupal.org/node/579722#comment-3114550
#5
Part of the problem here is that variables are not supposed to be passed to the t() function which given that the add / remove from queue link strings here are undefined in the module code they are variable and thus not a candidate for use by t().
From API docs: http://api.drupal.org/api/function/t/6
"Because t() is designed for handling code-based strings, in almost all cases, the actual string and not a variable must be passed through t().
Extraction of translations is done based on the strings contained in t() calls. If a variable is passed through t(), the content of the variable cannot be extracted from the file for translation."
See more discussion on this subject here:
http://groups.drupal.org/node/15177
#6
Hi everybody,
I find the solution to this problem.
On the nodequeue.module line 2278, you have to change :
$text = str_replace('%subqueue', $subqueue->title, $text);by
$text = str_replace('%subqueue', t($subqueue->title), t($text));So, you can add translation for your add/ remove link like :
Remove from the %subqueue listing ->Retirer du listing %subqueue
Add to the %subqueue listing : Ajouter au listing %subqueue
You can also add translation for your subqueue title
#7
Here's the patch against 6.x-2.x-dev corresponding to comment #6.
My editor removes unnecessary spaces, these are in the patch as well.
#8
Here's the patch against HEAD corresponding to comment #6.
My editor removes unnecessary spaces, these are in the patch as well.
#9
#10
Passing in t($text) as the 3rd (subject) seems like awkward use of str_replace().
Wouldn't correct use of t() really call for
$title = t($title, array('%subqueue' => $subqueue->title));?#11
jaydub is correct in #5, we can't use t() for user defined strings. The solution here would be to use i18nstrings from the i18n module.