|
|
Subject: Re: Taxonomy t() proposed to Drupal developers - msg#00554
List: php.drupal.devel
This patch does not fit with the current role of the locale subsystem,
which is to translate *interface* strings. None of the site specific
strings are run through t() currently. Gerhard is proposing that Drupal
should extend the usage of the locale system to the site specific
strings too... That is still to be discussed IMHO. :)
I would at least differentiate the non-interface t() calls with a st()
function or something... ('st' = site translation as opposed to 't'
being the interface translation). Then some meta info need to be added
to the site specific locale strings, so one can distinguish between them
on the admin interface and when generating .po files.
Goba
Michael Lessard wrote:
I added a few t() for locales
and t(term->description) to "title".
Although this is my newbie attempt, it works on the official Drupal 4.3.2.
Terms are translated, descriptions appear on mouse hover and are also
translated.
=> Minor quirk though: it outputs two | between terms as in:
node-term-A || node-term-B || etc.
ONCE THIS QUIRK IS FIXED, COULD SOMEONE TRY IT ON CVS?
(I have not created a CVS site yet)
/*
// PATCH AROUND LINE @37-55
function taxonomy_link($type, $node = NULL) {
if ($type == "system") {
if (user_access("administer taxonomy")) {
menu("admin/taxonomy", t("taxonomy"), "taxonomy_admin", 3);
menu("admin/taxonomy/add/vocabulary", t("create new vocabulary"),
"taxonomy_admin");
menu("admin/taxonomy/help", t("help"), "taxonomy_admin", 9);
}
}
else if ($type == "taxonomy terms" && $node != NULL) {
$links = array();
if ($node->taxonomy) {
foreach ($node->taxonomy as $tid) {
$term = taxonomy_get_term($tid);
- $links[] = l($term->name, "taxonomy/page/or/$term->tid");
+ $links[] = l(t($term->name), "taxonomy/page/or/$term->tid");
+ $links[] = l($text, "taxonomy/page/or/$term->tid", t($term->description) ?
array("title" => t($term->description)) : array());
}
}
else {
/*
** Themes can print taxonomy links with:
**
** if (module_exist("taxonomy")) {
** $this->links(taxonomy_link("taxonomy terms", $node));
** }
*/
$links = array();
foreach (taxonomy_node_get_terms($node->nid) as $term) {
- $links[] = l($term->name, "taxonomy/page/or/$term->tid");
+ $links[] = l(t($term->name), "taxonomy/page/or/$term->tid");
+ $links[] = l($text, "taxonomy/page/or/$term->tid", t($term->description) ?
array("title" => t($term->description)) : array());
}
}
return $links;
}
}
// --- End
* /
Was this page helpful?
Thread at a glance:
Previous Message by Date:
click to view message preview
[bug] broken taxonomy_overview() function
Project: Drupal
Version: cvs
Component: taxonomy.module
Category: bug reports
Priority: normal
Assigned to: spiderman
Reported by: spiderman
Updated by: Dries
Status: patch
Please attach your patch using the 'file attachment' form. Thanks. How
can we trigger/reproduce this problem?
Dries
Previous comments:
------------------------------------------------------------------------
February 9, 2004 - 03:48 : spiderman
i think this bug has existed since 4.3.0, where the taxonomy_overview
function does not generate the table data correctly for vocabularies
assigned to multiple node types. this patch corrects the problem.
[?php
--- ../drupal-4.3.2/modules/taxonomy.module 2003-10-22
09:03:32.000000000 -0400
+++ modules/taxonomy.module 2004-02-08 21:45:49.000000000 -0500
@@ -277,7 +277,13 @@
foreach ($vocabularies as $vocabulary) {
$links = array();
- $rows[] = array($vocabulary->name, array("data" =>
module_invoke($vocabulary->nodes, "node", "name"), "align" =>
"center"), l(t("edit vocabulary"),
"admin/taxonomy/edit/vocabulary/$vocabulary->vid"), l(t("add term"),
"admin/taxonomy/add/term/$vocabulary->vid"), l(t("preview form"),
"admin/taxonomy/preview/vocabulary/$vocabulary->vid"));
+
+ # build a list of node types
+ $types = array();
+ foreach (explode(",",$vocabulary->nodes) as $type) {
+ $types[] = module_invoke($type,"node","name") . $sep;
+ }
+ $rows[] = array($vocabulary->name, array("data" =>
implode(",",$types), "align" => "center"), l(t("edit vocabulary"),
"admin/taxonomy/edit/vocabulary/$vocabulary->vid"), l(t("add term"),
"admin/taxonomy/add/term/$vocabulary->vid"), l(t("preview form"),
"admin/taxonomy/preview/vocabulary/$vocabulary->vid"));
$tree = taxonomy_get_tree($vocabulary->vid);
if ($tree) {
?]
------------------------------------------------------------------------
February 9, 2004 - 04:22 : weitzman@xxxxxxxxxxxx
This is indeed a bug. However, the review team only considers patches
against CVS Drupal. The node system has changed enough that your patch
no longer applies. Please consider resubmitting.
------------------------------------------------------------------------
February 12, 2004 - 15:38 : spiderman
ok here's a new patch, against today's cvs version of taxonomy.module:
[?php
--- drupal/modules/taxonomy.module Thu Feb 12 09:33:59 2004
+++ patch/taxonomy.module Thu Feb 12 09:37:34 2004
@@ -284,7 +284,14 @@
foreach(explode(",", $vocabulary->nodes) as $type) {
$types[] = node_invoke($type, "node_name");
}
- $rows[] = array($vocabulary->name, array("data" => implode(", ",
$types), "align" => "center"), l(t("edit vocabulary"),
"admin/taxonomy/edit/vocabulary/$vocabulary->vid"), l(t("add term"),
"admin/taxonomy/add/term/$vocabulary->vid"), l(t("preview form"),
"admin/taxonomy/preview/vocabulary/$vocabulary->vid"));
+
+ # build a list of node types
+ $types = array();
+ foreach (explode(",",$vocabulary->nodes) as $type) {
+ $types[] = module_invoke($type,"node","name") . $sep;
+ }
+ $rows[] = array($vocabulary->name, array("data" =>
implode(",",$types), "align" => "center"), l(t("edit vocabulary"),
"admin/taxonomy/edit/vocabulary/$vocabulary->vid"), l(t("add term"),
"admin/taxonomy/add/term/$vocabulary->vid"), l(t("preview form"),
"admin/taxonomy/preview/vocabulary/$vocabulary->vid"));
+
$tree = taxonomy_get_tree($vocabulary->vid);
if ($tree) {
?]
------------------------------------------------------------------------
February 12, 2004 - 20:06 : Dries
Please attach your patch using the 'file attachment' form. Thanks.
--
View: http://drupal.org/node/view/5740
Edit: http://drupal.org/project/comments/add/5740
Next Message by Date:
click to view message preview
[task] Drupal_map_assoc - extending the platform
Project: Drupal
Version: cvs
Component: base system
Category: tasks
Priority: normal
Assigned to: Goba
Reported by: Goba
Updated by: Dries
-Status: patch
+Status: fixed
Committed to HEAD. Thanks.
Dries
Previous comments:
------------------------------------------------------------------------
February 2, 2004 - 16:07 : Goba
Attachment: http://drupal.org/files/issues/Drupal-map-assoc.patch (4.95 KB)
On the 24th of December, I have suggested [1] that a bunch of repeated
code could be elminated with modifying format_() functions to accept
arrays. That was turned down by Dries so then I came up [2] with a more
general solution to 'extend the Drupal platform' by adding a
drupal_map_assoc() function for module authors to use.
Here is an effort to turn this idea into a working patch and get the
support of someone who might commit it :) The idea behind this patch is
that there are a lot of places (most of the time settings, dropdowns)
when a function is called with different values repeatedly. The
function names overweight the actual parameter values and therefore it
is hard to have an overview of what is happening there... Since this
most of the time involves associative arrays, the approach is also a
possible typo point, since the array key and function parameter values
should be changed the same time.
My patch adds a general function to Drupal for any module to use. It
either converts an array to an associative array with the same values
and keys, or an array with keys and values with the function applied. I
have also included some examples of where this could help remove
repetition from the Drupal code, though there are more places to use
this. User.module is one perfect example, but I am waiting for another
patch to get accepted before I will next touch it :).
This patch is part of the continuation of my efforts to do more with
less and better organized code :)
[1] http://lists.drupal.org/archives/drupal-devel/2003-12/msg01029.html
[2] http://lists.drupal.org/archives/drupal-devel/2003-12/msg01137.html
------------------------------------------------------------------------
February 2, 2004 - 16:21 : Goba
Attachment: http://drupal.org/files/issues/Drupal-map-assoc_0.patch (4.95 KB)
Cosmetics: remove a trailing comma from the end of an array (regardless
of PHP allows it, it looked silly...)
------------------------------------------------------------------------
February 10, 2004 - 05:45 : weitzman@xxxxxxxxxxxx
to me, this patch cleans some ugly code and has no drawback.
------------------------------------------------------------------------
February 10, 2004 - 13:11 : Goba
And it will be able to clean a lot more, if this patch gets accepted :)
--
View: http://drupal.org/node/view/5592
Edit: http://drupal.org/project/comments/add/5592
Previous Message by Thread:
click to view message preview
Taxonomy t() proposed to Drupal developers
I added a few t() for locales
and t(term->description) to "title".
Although this is my newbie attempt, it works on the official Drupal 4.3.2.
Terms are translated, descriptions appear on mouse hover and are also
translated.
=> Minor quirk though: it outputs two | between terms as in:
node-term-A || node-term-B || etc.
ONCE THIS QUIRK IS FIXED, COULD SOMEONE TRY IT ON CVS?
(I have not created a CVS site yet)
/*
// PATCH AROUND LINE @37-55
function taxonomy_link($type, $node = NULL) {
if ($type == "system") {
if (user_access("administer taxonomy")) {
menu("admin/taxonomy", t("taxonomy"), "taxonomy_admin", 3);
menu("admin/taxonomy/add/vocabulary", t("create new vocabulary"),
"taxonomy_admin");
menu("admin/taxonomy/help", t("help"), "taxonomy_admin", 9);
}
}
else if ($type == "taxonomy terms" && $node != NULL) {
$links = array();
if ($node->taxonomy) {
foreach ($node->taxonomy as $tid) {
$term = taxonomy_get_term($tid);
- $links[] = l($term->name, "taxonomy/page/or/$term->tid");
+ $links[] = l(t($term->name), "taxonomy/page/or/$term->tid");
+ $links[] = l($text, "taxonomy/page/or/$term->tid",
t($term->description) ? array("title" => t($term->description)) : array());
}
}
else {
/*
** Themes can print taxonomy links with:
**
** if (module_exist("taxonomy")) {
** $this->links(taxonomy_link("taxonomy terms", $node));
** }
*/
$links = array();
foreach (taxonomy_node_get_terms($node->nid) as $term) {
- $links[] = l($term->name, "taxonomy/page/or/$term->tid");
+ $links[] = l(t($term->name), "taxonomy/page/or/$term->tid");
+ $links[] = l($text, "taxonomy/page/or/$term->tid", t($term->description)
? array("title" => t($term->description)) : array());
}
}
return $links;
}
}
// --- End
* /
Next Message by Thread:
click to view message preview
[feature] Vocab and Terms in Overview should be 'localizable'
Project: Taxonomy dhtml
Version: 4.3.0
Component: Code
Category: feature requests
Priority: critical
Assigned to: Anonymous
Reported by: mic
Updated by: mic
Status: active
In Drupal, it's pretty important that taxonomy modules (both core and
contributed) always present vocabularies and terms as localized (i.e.
can be translated with the locale.module).
In the Overview of taxonomy_dhtml, it's not the case.
It is in the block though.
I can't insert t() myself, because in the Overview, the function that
adds a count of the total number of nodes in a taxonomy is too codes
for me; I can't figure a way of translating the vocab or term before it
get converted to name=".( $count)."
Can somebody do this ?
It would be most helpful to many people I think.
Cheers,
Mic
mic
--
View: http://drupal.org/node/view/5822
Edit: http://drupal.org/project/comments/add/5822
|
|