Posted by walterhoct on March 16, 2007 at 1:40am
9 followers
| Project: | Case Tracker |
| Version: | 6.x-1.0-beta4 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
How can I translate Case state such as priority, type and status?
I am using the Internationalization module (i18n).
Comments
#1
Bumping version to HEAD, as this is something I'd like to see addressed.
#2
Update table strings in casetracker_case_states. Chears, Arto
#3
Please find the attached patch, which makes use of i18nstrings.module (if available) to make Case Tracker states translatable. (This is the first time I make strings translatable, so please correct me if I was following Making your custom data translatable the wrong way.)
#4
Previous patch had a bug: with that one there were wrong locale locations in the DB. Now this rerolled one has removed this bug, and it even has "refresh" capability.
#5
Sorry for submitting a git patch - I'm not too used to ancient things like cvs. Attaching a "proper" cvs patch now.
#6
Patch in #5 works as advertised.
That seems like the best approach as far as I can tell.
#7
The patch looks good. Just some tips:
- Instead of module_exists('i18nstrings') it's easier to implement some module's wrapper like
function casetracker_tt() {}Read about this here: http://drupal.org/node/609364
- The hook_locale($op = 'refresh') is deprecated, not needed anymore
- Maybe you'd save some code and improve performance by making the casetracker_realm_load() and/or casetracker_case_state_load() return the translated names. You can do it either by passing a $translate parameter or by adding a new property. I.e.
function casetracker_case_state_load($csid = NULL, $realm = NULL, $reset = FALSE) {
static $states_lookup;
if (!$states_lookup || $reset) {
....
while ($row = db_fetch_object($results)) {
$row->display = casetracker_tt("casetracker:$row->realm:$row->csid:name", $row->name);
$states_lookup[$row->realm][$row->csid] = $states_lookup['all'][$row->csid] = $row;
}
}
....
}
// Then you can use 'display' property instead of 'name' for printing out the value
#8
Reworked the patch following Jose's advices above.
#9
This latest one looks great. Just added some minor improvements:
- The textgroup 'casetracker' can be added by casetracker_tt(), will save some text
- The same function can be used too for casetracker_state_save(), saving some code
- The string id namespace: "[realm]:[csid]" replaced by "case_states:[csid]" (This is to avoid clashes in the future in case you have other types of objects translatable in this module, and other realms)
Re-rolled and tested. It works for the basic case of state names translation though may use some improvements in the future (translate other stuff, take a language parameter for cron/mails, etc, etc...)
#10
That works like a charm Jose
#11
works great for me too, thanks!
#12
Thanks all, this is committed.
#13
Automatically closed -- issue fixed for 2 weeks with no activity.
#14
This is an update for the latest i18nstrings (6.x-1.3) changes.
Right now it still works though it is using an obsoleted API, soon to be dropped.
#15
Thanks Jose, this has been committed.
#16
Automatically closed -- issue fixed for 2 weeks with no activity.
#17
Subscribing.