Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
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.)
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.
- 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
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...)
Comments
Comment #1
jmiccolis commentedBumping version to HEAD, as this is something I'd like to see addressed.
Comment #2
artol commentedUpdate table strings in casetracker_case_states. Chears, Arto
Comment #3
boobaaPlease 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.)
Comment #4
boobaaPrevious 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.
Comment #5
boobaaSorry for submitting a git patch - I'm not too used to ancient things like cvs. Attaching a "proper" cvs patch now.
Comment #6
svendecabooterPatch in #5 works as advertised.
That seems like the best approach as far as I can tell.
Comment #7
jose reyero commentedThe patch looks good. Just some tips:
- Instead of module_exists('i18nstrings') it's easier to implement some module's wrapper like
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.
Comment #8
boobaaReworked the patch following Jose's advices above.
Comment #9
jose reyero commentedThis 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...)
Comment #10
svendecabooterThat works like a charm Jose
Comment #11
castawaybcn commentedworks great for me too, thanks!
Comment #12
jmiccolis commentedThanks all, this is committed.
Comment #14
jose reyero commentedThis 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.
Comment #15
jmiccolis commentedThanks Jose, this has been committed.
Comment #17
sepla commentedSubscribing.