Download & Extend

Make case states translatable

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

Version:5.x-1.x-dev» master

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

Title:How to translate case state?» Make case states translatable
Version:master» 6.x-1.0-beta4
Component:User interface» Code
Category:support request» feature request
Status:active» needs review

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.)

AttachmentSize
casetracker-translatable_states.patch 3.06 KB

#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.

AttachmentSize
128228-casetracker-translatable_states-1.patch 3.38 KB

#5

Sorry for submitting a git patch - I'm not too used to ancient things like cvs. Attaching a "proper" cvs patch now.

AttachmentSize
128228-casetracker-translatable_states-2.patch 3.38 KB

#6

Patch in #5 works as advertised.
That seems like the best approach as far as I can tell.

#7

Status:needs review» needs work

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

Status:needs work» needs review

Reworked the patch following Jose's advices above.

AttachmentSize
128228-casetracker-translatable_states-3.patch 3.38 KB

#9

Status:needs review» reviewed & tested by the community

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...)

AttachmentSize
128228_casetracker_translatable_states.patch 3.78 KB

#10

That works like a charm Jose

#11

works great for me too, thanks!

#12

Status:reviewed & tested by the community» fixed

Thanks all, this is committed.

#13

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

#14

Status:closed (fixed)» needs review

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.

AttachmentSize
128228_casetracker_translatable_states_update.patch 1.95 KB

#15

Status:needs review» fixed

Thanks Jose, this has been committed.

#16

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

#17

Subscribing.